人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      ZendFramework2連接數(shù)據(jù)庫操作實(shí)例

ZendFramework2連接數(shù)據(jù)庫操作實(shí)例

標(biāo)簽: 發(fā)布日期:2017-04-18 00:00:00 279

本文實(shí)例講述了ZendFramework2連接數(shù)據(jù)庫操作。分享給大家供大家參考,具體如下:

相對于zf1,來說,zf2讓我們對于數(shù)據(jù)庫這方面的操作我的個人感覺是對于字段起別名簡單了,但是對數(shù)據(jù)庫的操作雖然配置寫好的就基本不需要動了,但是還是比1的配置要繁瑣,

還是那句話,大家可以去看看源碼。。。

Module.php 里面添加

public function getServiceConfig()
{
    return array(
      'factories' => array(
        'Student\Model\StudentTable' => function($sm) {
          $tableGateway = $sm->get('StudentTableGateway');
          $table = new StudentTable($tableGateway);
          return $table;
        },
        'StudentTableGateway' => function ($sm) {
          $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
          $resultSetPrototype = new ResultSet();
          $resultSetPrototype->setArrayObjectPrototype(new Student());
          return new TableGateway('cc_user', $dbAdapter, null, $resultSetPrototype);//table Name is cc_user
        },
      ),
    );
}