当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Adapter_Abstract::setFetchMode方法代码示例

本文整理汇总了PHP中Zend_Db_Adapter_Abstract::setFetchMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Abstract::setFetchMode方法的具体用法?PHP Zend_Db_Adapter_Abstract::setFetchMode怎么用?PHP Zend_Db_Adapter_Abstract::setFetchMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Adapter_Abstract的用法示例。


在下文中一共展示了Zend_Db_Adapter_Abstract::setFetchMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Create a new connection
  */
 private function connect()
 {
     $genericAdapterOptions = self::$genericAdapterOptions;
     $driverOptions = self::$driverOptions;
     $adapterParamaters = array('host' => $this->config->host, 'username' => $this->config->username, 'password' => $this->config->password, 'dbname' => $this->config->dbname, 'options' => &$genericAdapterOptions, 'driver_options' => &$driverOptions);
     $this->dbType = strtolower($this->config->get('db', 'mysql'));
     switch ($this->dbType) {
         case 'mysql':
             $adapter = 'Pdo_Mysql';
             /*
              * Set MySQL server SQL modes to behave as closely as possible to Oracle and PostgreSQL. Note that the
              * ONLY_FULL_GROUP_BY mode is left on purpose because MySQL requires you to specify all non-aggregate
              * columns in the group by list even if the query is grouped by the master table's primary key which is
              * valid ANSI SQL though. Further in that case the query plan would suffer if you add more columns to
              * the group by list.
              */
             $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION SQL_MODE=\'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,' . 'NO_AUTO_CREATE_USER,ANSI_QUOTES,PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION\';';
             $adapterParamaters['port'] = $this->config->get('port', 3306);
             break;
         case 'pgsql':
             $adapter = 'Pdo_Pgsql';
             $adapterParamaters['port'] = $this->config->get('port', 5432);
             if ($adapterParamaters['host'] === '') {
                 unset($adapterParamaters['host']);
             }
             break;
             /*case 'oracle':
               if ($this->dbtype === 'oracle') {
                   $attributes['persistent'] = true;
               }
               $this->db = ZfDb::factory($adapter, $attributes);
               if ($adapter === 'Oracle') {
                   $this->db->setLobAsString(false);
               }
               break;*/
         /*case 'oracle':
           if ($this->dbtype === 'oracle') {
               $attributes['persistent'] = true;
           }
           $this->db = ZfDb::factory($adapter, $attributes);
           if ($adapter === 'Oracle') {
               $this->db->setLobAsString(false);
           }
           break;*/
         default:
             throw new ConfigurationError('Backend "%s" is not supported', $this->dbType);
     }
     $this->dbAdapter = Zend_Db::factory($adapter, $adapterParamaters);
     $this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
     // TODO(el/tg): The profiler is disabled per default, why do we disable the profiler explicitly?
     $this->dbAdapter->getProfiler()->setEnabled(false);
 }
开发者ID:scibi,项目名称:icingaweb2,代码行数:55,代码来源:DbConnection.php

示例2: _authenticateQuerySelect

 /**
  * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and
  * performs a query against the database with that object.
  *
  * @param  Zend_Db_Select $dbSelect
  * @throws \Zend\Authentication\Adapter\Exception - when an invalid select
  *                                       object is encountered
  * @return array
  */
 protected function _authenticateQuerySelect(\Zend_Db_Select $dbSelect)
 {
     try {
         if ($this->_zendDb->getFetchMode() != \Zend_DB::FETCH_ASSOC) {
             $origDbFetchMode = $this->_zendDb->getFetchMode();
             $this->_zendDb->setFetchMode(\Zend_DB::FETCH_ASSOC);
         }
         $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString());
         if (isset($origDbFetchMode)) {
             $this->_zendDb->setFetchMode($origDbFetchMode);
             unset($origDbFetchMode);
         }
     } catch (\Exception $e) {
         throw new Exception('The supplied parameters to Zend\\Authentication\\Adapter\\DbTable failed to ' . 'produce a valid sql statement, please check table and column names ' . 'for validity.', 0, $e);
     }
     return $resultIdentities;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:26,代码来源:DbTable.php

示例3: _authenticateQuerySelect

 /**
  * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and
  * performs a query against the database with that object.
  *
  * @param Zend_Db_Select $dbSelect
  * @throws Zend_Auth_Adapter_Exception - when an invalid select
  *                                       object is encountered
  * @return array
  */
 protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect)
 {
     try {
         if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) {
             $origDbFetchMode = $this->_zendDb->getFetchMode();
             $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC);
         }
         $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString());
         if (isset($origDbFetchMode)) {
             $this->_zendDb->setFetchMode($origDbFetchMode);
             unset($origDbFetchMode);
         }
     } catch (Exception $e) {
         /**
          * @see Zend_Auth_Adapter_Exception
          */
         require_once 'Zend/Auth/Adapter/Exception.php';
         throw new Zend_Auth_Adapter_Exception('The supplied parameters to Zend_Auth_Adapter_DbTable failed to ' . 'produce a valid sql statement, please check table and column names ' . 'for validity.', 0, $e);
     }
     return $resultIdentities;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:30,代码来源:DbTable.php

示例4: _authenticateQuerySelect

 /**
  * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and
  * performs a query against the database with that object.
  *
  * @param Zend_Db_Select $dbSelect
  * @throws Zend_Auth_Adapter_Exception - when an invalid select
  *                                       object is encountered
  * @return array
  */
 protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect)
 {
     try {
         if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) {
             $origDbFetchMode = $this->_zendDb->getFetchMode();
             $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC);
         }
         $resultIdentities = $this->_zendDb->fetchAll($dbSelect);
         if (isset($origDbFetchMode)) {
             $this->_zendDb->setFetchMode($origDbFetchMode);
             unset($origDbFetchMode);
         }
     } catch (Exception $e) {
         /**
          * @see Zend_Auth_Adapter_Exception
          */
         require_once 'Zend/Auth/Adapter/Exception.php';
         throw new Zend_Auth_Adapter_Exception('O sistema falhou ao tentar executar o script de autenticação. ' . 'Por favor, entre em contato com o suporte ' . 'e informe o ocorrido..', 0, $e);
     }
     return $resultIdentities;
 }
开发者ID:romulotorres,项目名称:ZendBase,代码行数:30,代码来源:DbTable.php

示例5: _fetch

 /**
  * Support method for fetching rows.
  *
  * @param string       $type   Whether to fetch 'all' or 'row'.
  * @param string|array $where  OPTIONAL An SQL WHERE clause.
  * @param string|array $order  OPTIONAL An SQL ORDER clause.
  * @param int          $count  OPTIONAL An SQL LIMIT count.
  * @param int          $offset OPTIONAL An SQL LIMIT offset.
  * @return mixed               The row results per the Zend_Db_Adapter fetch mode.
  */
 protected function _fetch($type, $where = null, $order = null, $count = null, $offset = null)
 {
     // selection tool
     $select = $this->_db->select();
     // the FROM clause
     $select->from($this->_name, $this->_cols);
     // the WHERE clause
     $where = (array) $where;
     foreach ($where as $key => $val) {
         // is $key an int?
         if (is_int($key)) {
             // $val is the full condition
             $select->where($val);
         } else {
             // $key is the condition with placeholder,
             // and $val is quoted into the condition
             $select->where($key, $val);
         }
     }
     // the ORDER clause
     if (!is_array($order)) {
         $order = array($order);
     }
     foreach ($order as $val) {
         $select->order($val);
     }
     // the LIMIT clause
     $select->limit($count, $offset);
     // return the results
     $method = "fetch{$type}";
     $mode = $this->_db->getFetchMode();
     $this->_db->setFetchMode(Zend_Db::FETCH_ASSOC);
     $data = $this->_db->{$method}($select);
     $this->_db->setFetchMode($mode);
     return $data;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:46,代码来源:Abstract.php

示例6: setFetchMode

 /**
  * Set the fetch mode.
  *
  * @param integer $mode fetch mode
  * @return void
  * @throws Zend_Db_Adapter_Exception
  */
 public function setFetchMode($mode)
 {
     return $this->_adapter->setFetchMode($mode);
 }
开发者ID:cwcw,项目名称:cms,代码行数:11,代码来源:Abstract.php

示例7: connect

 /**
  * Create a new connection
  */
 private function connect()
 {
     $genericAdapterOptions = self::$genericAdapterOptions;
     $driverOptions = self::$driverOptions;
     $adapterParamaters = array('host' => $this->config->host, 'username' => $this->config->username, 'password' => $this->config->password, 'dbname' => $this->config->dbname, 'charset' => $this->config->charset ?: null, 'persistent' => (bool) $this->config->get('persistent', false), 'options' => &$genericAdapterOptions, 'driver_options' => &$driverOptions);
     $this->dbType = strtolower($this->config->get('db', 'mysql'));
     switch ($this->dbType) {
         case 'mssql':
             $adapter = 'Pdo_Mssql';
             $adapterParamaters['pdoType'] = $this->config->get('pdoType', 'dblib');
             break;
         case 'mysql':
             $adapter = 'Pdo_Mysql';
             if ($this->config->use_ssl) {
                 # The presence of these keys as empty strings or null cause non-ssl connections to fail
                 if ($this->config->ssl_key) {
                     $adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_KEY] = $this->config->ssl_key;
                 }
                 if ($this->config->ssl_cert) {
                     $adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_CERT] = $this->config->ssl_cert;
                 }
                 if ($this->config->ssl_ca) {
                     $adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_CA] = $this->config->ssl_ca;
                 }
                 if ($this->config->ssl_capath) {
                     $adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_CAPATH] = $this->config->ssl_capath;
                 }
                 if ($this->config->ssl_cipher) {
                     $adapterParamaters['driver_options'][PDO::MYSQL_ATTR_SSL_CIPHER] = $this->config->ssl_cipher;
                 }
             }
             /*
              * Set MySQL server SQL modes to behave as closely as possible to Oracle and PostgreSQL. Note that the
              * ONLY_FULL_GROUP_BY mode is left on purpose because MySQL requires you to specify all non-aggregate
              * columns in the group by list even if the query is grouped by the master table's primary key which is
              * valid ANSI SQL though. Further in that case the query plan would suffer if you add more columns to
              * the group by list.
              */
             $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION SQL_MODE=\'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,' . 'NO_AUTO_CREATE_USER,ANSI_QUOTES,PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION\'';
             if (isset($adapterParamaters['charset'])) {
                 $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', NAMES ' . $adapterParamaters['charset'];
                 unset($adapterParamaters['charset']);
             }
             $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= ';';
             $adapterParamaters['port'] = $this->config->get('port', 3306);
             break;
         case 'oci':
             $adapter = 'Oracle';
             unset($adapterParamaters['options']);
             unset($adapterParamaters['driver_options']);
             $adapterParamaters['driver_options'] = array('lob_as_string' => true);
             break;
         case 'oracle':
             $adapter = 'Pdo_Oci';
             break;
         case 'pgsql':
             $adapter = 'Pdo_Pgsql';
             $adapterParamaters['port'] = $this->config->get('port', 5432);
             break;
         default:
             throw new ConfigurationError('Backend "%s" is not supported', $this->dbType);
     }
     $this->dbAdapter = Zend_Db::factory($adapter, $adapterParamaters);
     $this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
     // TODO(el/tg): The profiler is disabled per default, why do we disable the profiler explicitly?
     $this->dbAdapter->getProfiler()->setEnabled(false);
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:70,代码来源:DbConnection.php


注:本文中的Zend_Db_Adapter_Abstract::setFetchMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。