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


PHP static::conn方法代碼示例

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


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

示例1: setConnection

 public static function setConnection($config = [])
 {
     if (static::$conn === null) {
         static::$conn = \Doctrine\DBAL\DriverManager::getConnection($config, new \Doctrine\DBAL\Configuration());
     }
     return static::$conn;
 }
開發者ID:hernandes,項目名稱:mithos,代碼行數:7,代碼來源:DriverManager.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $configDir = __DIR__ . '/../../../config';
     static::$structure = Structure::createFromYaml($configDir . '/structure.yml');
     static::$conn = (require_once $configDir . '/config.php');
     static::$mf = new ManagerFactory(static::$conn, static::$structure, true);
 }
開發者ID:dongww,項目名稱:simple-db,代碼行數:7,代碼來源:ManagerFactoryTest.php

示例3: __destruct

 public function __destruct()
 {
     if (!is_null(static::$conn)) {
         static::$conn->close();
         static::$conn = null;
     }
 }
開發者ID:pratapghanta,項目名稱:Group-Evaluation,代碼行數:7,代碼來源:Database.php

示例4: connect

 /**
  * @todo: Нужно переписать, что бы в качестве PDO можно было передать что-то другое - DI
  * @return mixed
  */
 protected function connect()
 {
     if (null === static::$conn) {
         static::$conn = new \PDO('mysql:host=' . $this->options['host'] . ';' . 'port=' . $this->options['port'] . ';', $this->options['user'], $this->options['password']);
     }
     return static::$conn;
 }
開發者ID:korhov,項目名稱:sphinx,代碼行數:11,代碼來源:Sphinx.php

示例5: connect

 static function connect()
 {
     if (!static::$conn) {
         static::$conn = mysqli_connect('localhost', getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'));
         mysqli_select_db(static::$conn, getenv('MYSQL_DB'));
     }
     return static::$conn;
 }
開發者ID:addquebec,項目名稱:site,代碼行數:8,代碼來源:DB.php

示例6: getconn

 static function getconn()
 {
     if (!static::$conn) {
         static::$conn = new mysqli(static::$servername, static::$username, static::$password, static::$dbname);
         if (static::$conn->connect_error) {
             die("Connection failed: ");
         }
     }
     return static::$conn;
 }
開發者ID:ahmadjainal,項目名稱:rpl2,代碼行數:10,代碼來源:db_connect.php

示例7: conn

 public static function conn()
 {
     if (static::$conn === null) {
         static::$config = new \Doctrine\DBAL\Configuration();
         $connectionParams = array('host' => Config::get('db_host'), 'driver' => 'pdo_mysql', 'user' => Config::get('db_login'), 'password' => Config::get('db_password'), 'dbname' => Config::get('db_name'), 'charset' => 'utf8');
         static::$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, static::$config);
         static::$conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     }
     return static::$conn;
 }
開發者ID:PayIcam,項目名稱:shotgun,代碼行數:10,代碼來源:Db.php

示例8: getConn

 /**
  * @return \Doctrine\DBAL\Connection
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Exception
  */
 public static function getConn()
 {
     $doctrineConfig = new Configuration();
     if (!empty(self::$conf)) {
         static::$conn = DriverManager::getConnection(self::$conf, $doctrineConfig);
     } else {
         throw new \Exception('Configuration problems');
     }
     return static::$conn;
 }
開發者ID:errogaht,項目名稱:pabtest2,代碼行數:15,代碼來源:DB.php

示例9: getConn

 /**
  * @return \Doctrine\DBAL\Connection
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Exception
  */
 public static function getConn()
 {
     if (null === static::$conn) {
         $doctrineConfig = new Configuration();
         $yaml = new Parser();
         $config = $yaml->parse(file_get_contents('pabtest-config.yml'));
         if (!empty($config['db'])) {
             static::$conn = DriverManager::getConnection($config['db'], $doctrineConfig);
         } else {
             throw new \Exception('Configuration problems');
         }
     }
     return static::$conn;
 }
開發者ID:errogaht,項目名稱:pabtest,代碼行數:19,代碼來源:DB.php

示例10: getInstance

 /**
 *
 Get the only object available
 */
 public static function getInstance()
 {
     //create an object of DBConnection
     if (null == static::$conn) {
         try {
             static::$conn = new PDO(sprintf("mysql:host=%s;dbname=%s", static::$HOSTNAME, static::$DATABASE), static::$USERNAME, static::$PASSWORD);
             //enable to throw error,otherwise can't throw error
             static::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } catch (PDOException $e) {
             print "Error!: " . $e->getMessage() . "<br/>";
             die;
         }
     }
     return static::$conn;
 }
開發者ID:shamim0754,項目名稱:AngularJs,代碼行數:19,代碼來源:DBConnection.php

示例11: setUp

 /**
  * Create database tables required for testing.
  *
  * @return array array of test data created
  */
 public static function setUp()
 {
     //Load environment variables
     $dotenv = new \Dotenv\Dotenv(__DIR__ . '/../../');
     if (!getenv('APP_ENV')) {
         $dotenv->load();
     }
     //Create connection and execute schema
     static::$conn = new Connection();
     Schema::createSchema();
     //Add test data to user table if not exist or no errors returned
     $user = User::firstOrCreate(['username' => 'test-root', 'password' => hash('SHA256', 'test-root')]);
     $emojiData = ['name' => 'Happy Face', 'char' => ':)', 'category' => 'Happy'];
     //Build keywords array and create users emojis
     $keywords = ['happy', 'face', 'emotion'];
     $emoji = $user->emojis()->firstOrCreate($emojiData);
     //Add keywords to keywords table
     $keyId = [];
     foreach ($keywords as $keyword) {
         $key = $emoji->keywords()->firstOrCreate(['name' => $keyword]);
         $keyId[] = $key->id;
     }
     return ['userId' => $user->id, 'emojiId' => $emoji->id, 'keywordsId' => $keyId];
 }
開發者ID:andela-gjames,項目名稱:Emoji-API,代碼行數:29,代碼來源:SetUpDb.php

示例12: Init

 /**
  * Initializes static fields, including a call to Columns() to get field types.
  */
 protected static function Init()
 {
     if (is_null(static::$table)) {
         static::$table = strtolower(get_called_class());
     }
     if (is_null(static::$conn) && isset($GLOBALS['conn'])) {
         static::$conn = $GLOBALS['conn'];
     }
     if (is_null(static::$cache) && isset($GLOBALS['cache'])) {
         static::$cache = $GLOBALS['cache'];
     }
     if (is_null(static::$columns)) {
         static::$columns = static::Columns();
     }
 }
開發者ID:Strikethegod,項目名稱:fanzub,代碼行數:18,代碼來源:class.activerecord.php

示例13: __construct

 public function __construct($conn)
 {
     $this->transactionID = rand();
     static::$conn = $conn;
 }
開發者ID:jobyone,項目名稱:glueframework,代碼行數:5,代碼來源:Transacter.php

示例14: __construct

 public function __construct($url)
 {
     if (is_null(static::$config) && isset($GLOBALS['config'])) {
         static::$config = $GLOBALS['config'];
     }
     if (is_null(static::$conn) && isset($GLOBALS['conn'])) {
         static::$conn = $GLOBALS['conn'];
     }
     if (is_null(static::$cache) && isset($GLOBALS['cache'])) {
         static::$cache = $GLOBALS['cache'];
     }
     if (is_null(static::$session) && isset($GLOBALS['session'])) {
         static::$session = $GLOBALS['session'];
     }
     $this->url = $url;
     $this->Init();
 }
開發者ID:Strikethegod,項目名稱:fanzub,代碼行數:17,代碼來源:class.framework.php

示例15: configureDB

 public static function configureDB($dsn, $username, $password)
 {
     static::$conn = DB::getConnection($dsn, $username, $password);
 }
開發者ID:jobyone,項目名稱:glueframework,代碼行數:4,代碼來源:CRUDder.php


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