当前位置: 首页>>代码示例>>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;未经允许,请勿转载。