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


PHP mysqli::getConnection方法代碼示例

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


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

示例1: quoteTrustedValue

 /**
  * Quote Trusted Value
  *
  * The ability to quote values without notices
  *
  * @param $value
  * @return mixed
  */
 public function quoteTrustedValue($value)
 {
     if ($this->resource instanceof DriverInterface) {
         $this->resource = $this->resource->getConnection()->getResource();
     }
     if ($this->resource instanceof \mysqli) {
         return '\'' . $this->resource->real_escape_string($value) . '\'';
     }
     if ($this->resource instanceof \PDO) {
         return $this->resource->quote($value);
     }
     return '\'' . addcslashes($value, "\n\r\\'\"") . '\'';
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:21,代碼來源:Mysql.php

示例2: setDriver

 /**
  * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo||\mysqli|\PDO $driver
  * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
  * @return $this
  */
 public function setDriver($driver)
 {
     // handle Zend_Db drivers
     if ($driver instanceof Mysqli\Mysqli || $driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Mysql') {
         /** @var $driver \Zend\Db\Adapter\Driver\DriverInterface */
         $this->resource = $driver->getConnection()->getResource();
         return $this;
     }
     // handle
     if ($driver instanceof \mysqli || $driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql') {
         $this->resource = $driver;
         return $this;
     }
     throw new Exception\InvalidArgumentException('$driver must be a Mysqli or Mysql PDO Zend\\Db\\Adapter\\Driver, Mysqli instance or MySQL PDO instance');
 }
開發者ID:totolouis,項目名稱:ZF2-Auth,代碼行數:20,代碼來源:Mysql.php


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