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


PHP Connection::getConn方法代碼示例

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


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

示例1: testConexaoAoBancoDeDados

 public function testConexaoAoBancoDeDados()
 {
     $config = new Configurator(['dsn' => 'mysql:host=localhost;dbname=php_praticas_modernas', 'user' => 'root', 'pass' => '123', 'config' => []]);
     $conn = new Connection($config);
     $conn->conn();
     $pdo = $conn->getConn();
     $this->assertInstanceOf('PDO', $pdo);
 }
開發者ID:Raro01,項目名稱:php-praticas-modernas-turma-1,代碼行數:8,代碼來源:ConnectionTest.php

示例2: endEvent

 public function endEvent()
 {
     $conn = Connection::getConn();
     $sql = "UPDATE CrawlEvents SET event_end = CURRENT_TIMESTAMP WHERE nct_id = ?";
     $stmt = $conn->prepare($sql);
     $stmt->bindValue(1, $this->nct_id);
     $stmt->execute();
     return TRUE;
 }
開發者ID:bschatzman,項目名稱:new-project,代碼行數:9,代碼來源:collect.php

示例3: _factory

 private function _factory($database)
 {
     if (empty($database)) {
         throw new Exception('No database specified.', 501);
     }
     if (empty(static::$queryBuilderInstance[$database])) {
         $connection = Connection::getConn($database);
         static::$queryBuilderInstance[$database] = new QueryBuilder($connection);
     }
     static::$database = static::$queryBuilderInstance[$database]->getConnection()->getDatabase();
     return static::$queryBuilderInstance[$database];
 }
開發者ID:WickyLeo,項目名稱:bobcat,代碼行數:12,代碼來源:DB.class.php

示例4: init

 /**
  * Método que dispara o projeto
  * - Fax a conexão como banco utilizando o array $connection
  * - Especifica o TablePrefix
  * - Especifica a topLevelClass
  * - Faz o tratamento da URL
  * - Exibe o tratamento chamando a URL
  *
  * @return void
  */
 public static function init()
 {
     define("PROTOCOLO", 'http://');
     self::$configurationArray = parse_ini_file(self::$globalConfiurationFile, true);
     if (!defined('WEB_DIR')) {
         define('WEB_DIR', self::$configurationArray['project']['directory']);
     }
     if (!defined("WEB_URL")) {
         define("WEB_URL", self::$configurationArray['project']['url']);
     }
     if (!defined("SMARTY_DIR")) {
         define("SMARTY_DIR", WEB_DIR . "classes/smarty/");
     }
     set_include_path(WEB_DIR . 'classes/smarty/' . PATH_SEPARATOR . WEB_DIR . 'classes/' . PATH_SEPARATOR . ".");
     /*******************************************************************************
      * AUTO_LOAD
      * define se o método mágico para autoload de classes esta ativo
      ******************************************************************************/
     if (Samus::$useAutoloadFunction) {
         require_once 'util/AutoRequire.php';
         function __autoload($className)
         {
             AutoRequire::showSugests();
             AutoRequire::requireClass($className);
         }
     }
     include_once 'samus/Samus_Keeper.php';
     require_once 'samus/Samus_Exception.php';
     require_once 'samus/Samus_Model.php';
     require_once 'samus/Samus_Filter.php';
     require_once 'CRUD/Properties.php';
     require_once 'CRUD/TableFactory.php';
     require_once 'samus/Samus_Object.php';
     require_once 'database/Connection.php';
     require_once 'CRUD/CRUDQuery.php';
     require_once 'database/ConnectionMySqli.php';
     ////////////////////////////////////////////////////////////////////////
     // CONFIGURAÇÃO DA CONEXÃO
     // faz a configuração da conexão a partir do global_configuration.ini
     ////////////////////////////////////////////////////////////////////////
     self::setConnection(self::$configurationArray['connection']);
     // lê arquivo de conexão e realiza a conexão
     CRUDQuery::setModo(self::$connection["queryMode"]);
     if (self::$connection["queryMode"] == CRUDQuery::QUERY_MODE_MYSQLI) {
         ConnectionMySqli::connect(self::$connection['name'], self::$connection['user'], self::$connection['password'], self::$connection['host'], self::$connection['charset'], self::$connection['engine']);
         CRUDQuery::setConn(ConnectionMySqli::getConn());
         // essalinha ta meio redundante verificar depois
         CRUD::setConn(ConnectionMySqli::getConn());
     } else {
         Connection::connect(self::$connection['adapter'], self::$connection['host'], self::$connection['name'], self::$connection['user'], self::$connection['password']);
         CRUDQuery::setConn(Connection::getConn());
         CRUD::setConn(Connection::getPdo());
     }
     self::$tablePrefix = self::$connection["table_prefix"];
     CRUD::$tablePrefix = self::getTablePrefix();
     CRUD::$topLevelClass = "Samus_Model";
     ////////////////////////////////////////////////////////////////////////
     // EXIBINDO AS PÁGINAS
     // aqui o fazendeiro exibe as páginas
     ////////////////////////////////////////////////////////////////////////
     self::setHttpHost($_GET['httpHost']);
     $samus_keeper = new Samus_Keeper($_GET['__cod'], $_GET['httpHost']);
     $samus_keeper->displayPage();
 }
開發者ID:laiello,項目名稱:samusframework,代碼行數:74,代碼來源:Samus.php

示例5: unset

     $stmt = $conn->prepare($sql);
     try {
         $stmt->execute(array(':search_string' => $item . '%'));
         $rows = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
         $conn = null;
         unset($stmt);
         echo json_encode($rows);
     } catch (PDOException $e) {
         echo "\n" . "Query failed:  " . $e->getMessage();
         $conn = null;
         unset($stmt);
         return true;
     }
     break;
 case 'Sponsors':
     $conn = Connection::getConn();
     $sql = "SELECT DISTINCT lead_sponsor FROM ClinicalTrials WHERE lead_sponsor LIKE :search_string";
     $stmt = $conn->prepare($sql);
     try {
         $stmt->execute(array(':search_string' => $item . '%'));
         $rows = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
         $conn = null;
         unset($stmt);
         echo json_encode($rows);
     } catch (PDOException $e) {
         echo "\n" . "Query failed:  " . $e->getMessage();
         $conn = null;
         unset($stmt);
         return true;
     }
     break;
開發者ID:bschatzman,項目名稱:new-project,代碼行數:31,代碼來源:controller.php


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