当前位置: 首页>>代码示例>>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;未经允许,请勿转载。