當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Db_Adapter_Abstract::getConnection方法代碼示例

本文整理匯總了PHP中Zend_Db_Adapter_Abstract::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Db_Adapter_Abstract::getConnection方法的具體用法?PHP Zend_Db_Adapter_Abstract::getConnection怎麽用?PHP Zend_Db_Adapter_Abstract::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Db_Adapter_Abstract的用法示例。


在下文中一共展示了Zend_Db_Adapter_Abstract::getConnection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _execScripts

 /**
  * Wykonuje wiele zapytań SQL'owych.
  *
  * @param array $aSql
  */
 protected function _execScripts(array $aSql)
 {
     $oConnection = $this->_oDBAdapter->getConnection();
     $bBug = false;
     foreach ($aSql as $sSql) {
         try {
             $oConnection->exec($sSql);
         } catch (Exception $e) {
             switch ($this->_oConfig->db->adapter) {
                 case 'PDO_PGSQL':
                     if (!stristr($e->getMessage(), '42P07')) {
                         throw new Exception($e->getMessage());
                         $bBug = true;
                     }
                     break;
                 default:
                     throw new Exception($e->getMessage());
                     $bBug = true;
                     break;
             }
         }
     }
     if ($bBug) {
         throw new Exception("błąd");
     }
 }
開發者ID:Webowiec,項目名稱:zendnote,代碼行數:31,代碼來源:Base.php

示例2: _setUpAdapter

 /**
  * Open a new database connection
  */
 protected function _setUpAdapter()
 {
     $this->_db = \Zend\DB\DB::factory($this->getDriver(), $this->_util->getParams());
     try {
         $conn = $this->_db->getConnection();
     } catch (\Zend\Exception $e) {
         $this->_db = null;
         $this->assertType('Zend\\DB\\Adapter\\Exception', $e, 'Expecting Zend_Db_Adapter_Exception, got ' . get_class($e));
         $this->markTestSkipped($e->getMessage());
     }
 }
開發者ID:hjr3,項目名稱:zf2,代碼行數:14,代碼來源:TestSetup.php

示例3: array

 function __construct($config = array())
 {
     // set a Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $db = $config['db'];
         // use an object from the registry?
         if (is_string($db)) {
             $db = Zend::registry($db);
         }
         // make sure it's a Zend_Db_Adapter
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             throw new Varien_Db_Tree_Exception('db object does not implement Zend_Db_Adapter_Abstract');
         }
         // save the connection
         $this->_db = $db;
         $conn = $this->_db->getConnection();
         if ($conn instanceof PDO) {
             $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         } elseif ($conn instanceof mysqli) {
             //TODO: ???
         }
     } else {
         throw new Varien_Db_Tree_Exception('db object is not set in config');
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
開發者ID:chucky515,項目名稱:Magento-CE-Mirror,代碼行數:54,代碼來源:Tree.php

示例4: _setUpAdapter

 /**
  * Open a new database connection
  */
 protected function _setUpAdapter()
 {
     $this->_db = Zend_Db::factory($this->getDriver(), $this->_util->getParams());
     try {
         $conn = $this->_db->getConnection();
     } catch (Zend_Exception $e) {
         $this->_db = null;
         $this->assertTrue($e instanceof Zend_Db_Adapter_Exception, 'Expecting Zend_Db_Adapter_Exception, got ' . get_class($e));
         $this->markTestSkipped($e->getMessage());
     }
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:14,代碼來源:TestSetup.php

示例5: tearDown

 /**
  * Drop test table and close connection.
  */
 public function tearDown()
 {
     $this->tearDownMetadata();
     $connection = $this->_db->getConnection();
     $connection = null;
     $this->_db = null;
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:10,代碼來源:Common.php

示例6: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `page_horisontal`
(
       id INTEGER NOT NULL,
       name TEXT,
       resource TEXT,
       PRIMARY KEY(id)
);
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oSqliteConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:17,代碼來源:PageHorisontalMapperSqliteTest.php

示例7: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `page_imposition`
(
       id INTEGER NOT NULL,
       page_id INTEGER NOT NULL,
       is_linked_to INTEGER NOT NULL,
       position_type TEXT NOT NULL,
       PRIMARY KEY(id)
);
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:18,代碼來源:PageImpositionMapperSqliteTest.php

示例8: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `page`
(
       id INTEGER NOT NULL,
       title TEXT NOT NULL,
       horisontal_page_id INTEGER NOT NULL DEFAULT "-1",
       template INTEGER NOT NULL DEFAULT "-1" ,
       machine_name TEXT,
       color TEXT,
       PRIMARY KEY(id)
)
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oSqliteConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:20,代碼來源:PageMapperSqliteTest.php

示例9: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `menu`
(
       id INTEGER NOT NULL,
       title TEXT,
       firstpage_id INTEGER,
       description TEXT,
       thumb_stripe TEXT,
       thumb_summary TEXT,
       color TEXT,
       PRIMARY KEY(id)
);
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oSqliteConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:21,代碼來源:TermMapperSqliteTest.php

示例10: __construct

 /**
  * @param array $config
  * @throws LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct($config = [])
 {
     // set a \Zend_Db_Adapter connection
     if (!empty($config['db'])) {
         // convenience variable
         $connection = $config['db'];
         // use an object from the registry?
         if (is_string($connection)) {
             $connection = \Zend::registry($connection);
         }
         // make sure it's a \Zend_Db_Adapter
         if (!$connection instanceof \Zend_Db_Adapter_Abstract) {
             throw new LocalizedException(new \Magento\Framework\Phrase('db object does not implement \\Zend_Db_Adapter_Abstract'));
         }
         // save the connection
         $this->_db = $connection;
         $conn = $this->_db->getConnection();
         if ($conn instanceof \PDO) {
             $conn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
         }
     } else {
         throw new LocalizedException(new \Magento\Framework\Phrase('db object is not set in config'));
     }
     if (!empty($config['table'])) {
         $this->setTable($config['table']);
     }
     if (!empty($config['id'])) {
         $this->setIdField($config['id']);
     } else {
         $this->setIdField('id');
     }
     if (!empty($config['left'])) {
         $this->setLeftField($config['left']);
     } else {
         $this->setLeftField('left_key');
     }
     if (!empty($config['right'])) {
         $this->setRightField($config['right']);
     } else {
         $this->setRightField('right_key');
     }
     if (!empty($config['level'])) {
         $this->setLevelField($config['level']);
     } else {
         $this->setLevelField('level');
     }
     if (!empty($config['pid'])) {
         $this->setPidField($config['pid']);
     } else {
         $this->setPidField('parent_id');
     }
 }
開發者ID:vasiljok,項目名稱:magento2,代碼行數:58,代碼來源:Tree.php

示例11: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `element`
(
       id INTEGER NOT NULL,
       page_id INTEGER NOT NULL,
       element_type_name TEXT NOT NULL,
       weight INTEGER NOT NULL,
       content_text  BLOB,
       PRIMARY KEY(id)
);

CREATE TABLE `element_data`
(
       id INTEGER NOT NULL,
       element_id INTEGER NOT NULL,
       type TEXT NOT NULL,
       value TEXT NOT NULL,
       position_id  INTEGER,
       PRIMARY KEY(id)
);

CREATE TABLE `element_data_position`
(
       id INTEGER,
       start_x INTEGER,
       start_y INTEGER,
       end_x INTEGER,
       end_y INTEGER,
       PRIMARY KEY(id)
);
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:39,代碼來源:ElementWithPdfInfoMapperSqliteTest.php

示例12: getAdapter

 /**
  * Establish connection and create DB
  *
  * @return Zend_Db_Adapter_Pdo_Sqlite
  * @throws AM_Handler_Export_Sqlite_Exception
  */
 public function getAdapter()
 {
     if (is_null($this->_oAdapter)) {
         $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $this->_getDbFile()));
         $sSchema = @file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Sqlite' . DIRECTORY_SEPARATOR . 'schema.sqlite.sql');
         if (empty($sSchema)) {
             throw new AM_Handler_Export_Sqlite_Exception('Schema file is empty');
         }
         $this->_oAdapter->getConnection()->exec($sSchema);
         AM_Tools_Standard::getInstance()->chmod($this->_getDbFile(), 0666);
     }
     return $this->_oAdapter;
 }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:19,代碼來源:Sqlite.php

示例13: _setUpAdapter

 /**
  * Open a new database connection
  */
 protected function _setUpAdapter()
 {
     $params = $this->_util->getParams();
     $params['adapterNamespace'] = 'ZendX_Db_Adapter';
     $this->_db = Zend_Db::factory($this->getDriver(), $params);
     try {
         $conn = $this->_db->getConnection();
     } catch (Zend_Exception $e) {
         $this->_db = null;
         $this->assertType('Zend_Db_Adapter_Exception', $e, 'Expecting Zend_Db_Adapter_Exception, got ' . get_class($e));
         $this->markTestSkipped($e->getMessage());
     }
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:16,代碼來源:TestSetup.php

示例14: _prepareSqliteAdapter

    protected function _prepareSqliteAdapter()
    {
        $sDbName = AM_Handler_Temp::getInstance()->getFile();
        $this->_oAdapter = Zend_Db::factory('PDO_SQLITE', array('dbname' => $sDbName));
        $sSql = <<<SQL
CREATE TABLE `element`
(
       id INTEGER NOT NULL,
       page_id INTEGER NOT NULL,
       element_type_name TEXT NOT NULL,
       weight INTEGER NOT NULL,
       content_text  BLOB,
       PRIMARY KEY(id)
);

CREATE TABLE `element_data`
(
       id INTEGER NOT NULL,
       element_id INTEGER NOT NULL,
       type TEXT NOT NULL,
       value TEXT NOT NULL,
       position_id  INTEGER,
       PRIMARY KEY(id)
);

CREATE TABLE `game_crossword`
(
       id INTEGER NOT NULL,
       title TEXT,
       grid_width INTEGER,
       grid_height INTEGER,
       PRIMARY KEY(id)
);

CREATE TABLE `game_crossword_word`
(
       id INTEGER NOT NULL,
       game INTEGER NOT NULL,
       answer TEXT NOT NULL,
       question TEXT NOT NULL,
       length INTEGER DEFAULT NULL,
       direction  TEXT NOT NULL,
       start_x INTEGER NOT NULL,
       start_y INTEGER NOT NULL,
       PRIMARY KEY(id)
);
SQL;
        $this->_oAdapter->getConnection()->exec($sSql);
        $this->_oConnectionMock = $this->createZendDbConnection($this->_oAdapter, $sDbName);
        return $this;
    }
開發者ID:pansot2,項目名稱:PadCMS-backend,代碼行數:51,代碼來源:CrosswordGameMapperSqliteTest.php

示例15: __call

 /**
  * Delegate to the database adapter.
  * 
  * @param string $m Method name.
  * @param array $a Method arguments.
  * @return mixed
  */
 public function __call($m, $a)
 {
     if (!method_exists($this->_adapter, $m)) {
         throw new BadMethodCallException("Method named '{$m}' does not exist or is not callable.");
     }
     // Log SQL for certain adapter calls.
     $logFor = array('fetchOne', 'fetchAll', 'prepare', 'query', 'fetchRow', 'fetchAssoc', 'fetchCol', 'fetchPairs');
     if (in_array($m, $logFor)) {
         $this->log($a[0]);
     }
     try {
         return call_user_func_array(array($this->_adapter, $m), $a);
         // Zend_Db_Statement_Mysqli does not consider a connection that returns
         // a "MySQL server has gone away" error to be disconnected. Catch these
         // errors, close the connection, and reconnect, then retry the query.
     } catch (Zend_Db_Statement_Mysqli_Exception $e) {
         if (2006 == $e->getCode()) {
             $this->_adapter->closeConnection();
             $this->_adapter->getConnection();
             return call_user_func_array(array($this->_adapter, $m), $a);
         }
         throw $e;
     }
 }
開發者ID:lchen01,項目名稱:STEdwards,代碼行數:31,代碼來源:Db.php


注:本文中的Zend_Db_Adapter_Abstract::getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。