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


PHP Zend_Db_Adapter_Pdo_Mysql::_connect方法代码示例

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


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

示例1: _connect

 /**
  * Connects to the database.
  *
  */
 protected function _connect()
 {
     parent::_connect();
     if (!$this->_initialized) {
         $this->_initialized = true;
         if ($this->_config['timezone']) {
             // Requires PHP 5.2+
             $dtz = new DateTimeZone($this->_config['timezone']);
             $offset = $dtz->getOffset(new DateTime('NOW')) / 60 / 60;
             if ($offset > 0) {
                 $offset = "+" . $offset;
             }
             /*
             echo "location: ".$dtz->getLocation()."<br />";
             echo "offset: ".$dtz->getOffset(new DateTime('NOW'))."<br />";
             echo "offset 2: ". $offset."<br />";
             echo "SET time_zone = '$offset:00'"."<br />";
             */
             $this->query("SET time_zone = '{$offset}:00';");
             //sprintf("SET time_zone = '%d:00'", $offset));
             /*
                             $timezone = new DateTimeZone($this->_config['timezone']);
                             $minutes = $timezone->getOffset(new DateTime('NOW')) / 60 / 60;
                             
                             
                             
                             //$offset = sprintf("SET time_zone = '%d:%2d'", $minutes / 60, $minutes % 60);
                             $offset = sprintf("SET time_zone = '%d:00'", $offset);
             *
             */
         }
     }
 }
开发者ID:lschnoller,项目名称:boonding,代码行数:37,代码来源:Mysql.php

示例2: _connect

 /**
  * Modifies standard connection behavior to use UTF-8.
  *
  * @return void
  */
 protected function _connect()
 {
     // if we already have a PDO object, no need to re-connect.
     if (is_null($this->_connection) === false) {
         return;
     }
     $config = Zend_Registry::get('Zend_Config');
     if (isset($config, $config->db->debug) && $config->db->debug) {
         $logger = Zend_Registry::get('Zend_Log');
         $logger->debug("Mysqlutf8: created new adapter");
         $backtrace = debug_backtrace(false);
         foreach ($backtrace as $row) {
             $file = array_key_exists('file', $row) ? $row['file'] : '_no_file_)';
             $line = array_key_exists('line', $row) ? $row['line'] : '0';
             $function = array_key_exists('function', $row) ? $row['function'] : '_no_function_';
             $optional = '';
             if ($row['function'] == 'query' && !is_null($row['args'][0])) {
                 $optional = "(" . $row['args'][0] . ")";
             }
             $logger->debug("Mysqlutf8: {$file}:{$line} at {$function} {$optional}");
         }
     }
     parent::_connect();
     // set connection to utf8
     $this->query('SET NAMES utf8');
     // Enable "strict" mode on all transactional tables to avoid silent
     // truncation of inserted/updated data.  See ticket [OPUSVIER-2111].
     // $this->query("SET sql_mode = 'STRICT_TRANS_TABLES'");
 }
开发者ID:alexukua,项目名称:opus4,代码行数:34,代码来源:Mysqlutf8.php

示例3: _connect

 /**
  * Connects to the database. This method is overridden because we need to set
  * some connection params that are not set by default, and that developers might
  * forget to set. Also addional checks are provided
  *
  * @return void
  * @throws Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!extension_loaded('pdo_mysql')) {
         require_once 'Zend/Db/Adapter/Exception.php';
         throw new Zend_Db_Adapter_Exception('pdo_mysql extension is not installed');
     }
     if (array_key_exists('host', $this->_config)) {
         if (strpos($this->_config['host'], '/') !== false) {
             $this->_config['unix_socket'] = $this->_config['host'];
             unset($this->_config['host']);
         } elseif (strpos($this->_config['host'], ':') !== false) {
             list($this->_config['host'], $this->_config['port']) = explode(':', $this->_config['host']);
         }
     }
     parent::_connect();
     /** @link http://bugs.mysql.com/bug.php?id=18551 */
     // dont know if we want this behaviour, check the link above
     $this->_connection->query("SET SQL_MODE=''");
     $this->_connection->query("SET NAMES 'utf8'");
     if (!$this->_connectionFlagsSet) {
         $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         $this->_connectionFlagsSet = true;
     }
 }
开发者ID:cwcw,项目名称:cms,代码行数:35,代码来源:Mysql.php

示例4: _connect

 protected function _connect()
 {
     // if we already have a PDO object, no need to re-connect.
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     // set connection to utf8
     $this->query('SET NAMES utf8');
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:10,代码来源:Mysql.php

示例5: _connect

 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!empty($this->_config['timeout'])) {
         $this->_config['driver_options'][PDO::ATTR_TIMEOUT] = $this->_config['timeout'];
     }
     parent::_connect();
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:16,代码来源:Mysql.php

示例6: _connect

 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     if (isset($this->_config['options']['init_commands']) && is_array($this->_config['options']['init_commands'])) {
         foreach ($this->_config['options']['init_commands'] as $sqlInitCommand) {
             $this->_connection->exec($sqlInitCommand);
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:Mysql.php

示例7: _connect

 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     // if we already have a PDO object, no need to re-connect.
     if ($this->_connection) {
         return;
     }
     try {
         parent::_connect();
     } catch (Exception $e) {
         $message = $e->getMessage();
         $message = str_replace(array($this->_config['username'], $this->_config['password']), '******', $message);
         throw new Zend_Db_Adapter_Exception($message, $e->getCode(), $e->getPrevious());
     }
     // finally, we delete the authorization data
     unset($this->_config['username'], $this->_config['password']);
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:22,代码来源:Mysql.php

示例8: _connect

 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!extension_loaded('pdo_mysql')) {
         throw new Zend_Db_Adapter_Exception('pdo_mysql extension is not installed');
     }
     if (strpos($this->_config['host'], '/') !== false) {
         $this->_config['unix_socket'] = $this->_config['host'];
         $this->_config['host'] = null;
     } elseif (strpos($this->_config['host'], ':') !== false) {
         list($this->_config['host'], $this->_config['port']) = explode(':', $this->_config['host']);
     }
     parent::_connect();
     /** @link http://bugs.mysql.com/bug.php?id=18551 */
     $this->_connection->query("SET SQL_MODE=''");
     if (!$this->_connectionFlagsSet) {
         $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         #$this->_connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
         $this->_connectionFlagsSet = true;
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:23,代码来源:Mysql.php

示例9: _connect

 /**
  * Creates a PDO object and connects to the database.
  *
  * @throws Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!extension_loaded('pdo_mysql')) {
         throw new Zend_Db_Adapter_Exception('pdo_mysql extension is not installed');
     }
     $hostInfo = $this->_getHostInfo($this->_config['host']);
     switch ($hostInfo->getAddressType()) {
         case self::ADDRESS_TYPE_UNIX_SOCKET:
             $this->_config['unix_socket'] = $hostInfo->getUnixSocket();
             unset($this->_config['host']);
             break;
         case self::ADDRESS_TYPE_IPV6_ADDRESS:
             // break intentionally omitted
         // break intentionally omitted
         case self::ADDRESS_TYPE_IPV4_ADDRESS:
             // break intentionally omitted
         // break intentionally omitted
         case self::ADDRESS_TYPE_HOSTNAME:
             $this->_config['host'] = $hostInfo->getHostName();
             if ($hostInfo->getPort()) {
                 $this->_config['port'] = $hostInfo->getPort();
             }
             break;
         default:
             break;
     }
     $this->_debugTimer();
     parent::_connect();
     $this->_debugStat(self::DEBUG_CONNECT, '');
     /** @link http://bugs.mysql.com/bug.php?id=18551 */
     $this->_connection->query("SET SQL_MODE=''");
     if (!$this->_connectionFlagsSet) {
         $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
         $this->_connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
         $this->_connectionFlagsSet = true;
     }
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:45,代码来源:Mysql.php

示例10: _connect

 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws \Zend_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!extension_loaded('pdo_mysql')) {
         throw new \Zend_Db_Adapter_Exception('pdo_mysql extension is not installed');
     }
     if (!isset($this->_config['host'])) {
         throw new \Zend_Db_Adapter_Exception('No host configured to connect');
     }
     if (strpos($this->_config['host'], '/') !== false) {
         $this->_config['unix_socket'] = $this->_config['host'];
         unset($this->_config['host']);
     } elseif (strpos($this->_config['host'], ':') !== false) {
         list($this->_config['host'], $this->_config['port']) = explode(':', $this->_config['host']);
     }
     $this->logger->startTimer();
     parent::_connect();
     $this->logger->logStats(LoggerInterface::TYPE_CONNECT, '');
     /** @link http://bugs.mysql.com/bug.php?id=18551 */
     $this->_connection->query("SET SQL_MODE=''");
     if (!$this->_connectionFlagsSet) {
         $this->_connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
         $this->_connection->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
         $this->_connectionFlagsSet = true;
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:Mysql.php


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