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


PHP Db::connection方法代碼示例

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


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

示例1: getConnection

 protected static function getConnection()
 {
     if (!self::$connection) {
         self::$connection = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
     }
     return self::$connection;
 }
開發者ID:gpichurov,項目名稱:ittalents_season5,代碼行數:7,代碼來源:Db.php

示例2: getInstance

 public static function getInstance()
 {
     if (!self::$connection) {
         self::$connection = new self();
     }
     return self::$connection;
 }
開發者ID:gonpombo,項目名稱:Laboratorio,代碼行數:7,代碼來源:Db.php

示例3: getTermInfo

 public function getTermInfo($condition)
 {
     $db = Db::connection($this->connection)->table($this->table);
     $db = $this->formatCondition($db, $condition);
     $res = $db->first();
     return $res;
 }
開發者ID:nosun,項目名稱:laravel_base,代碼行數:7,代碼來源:Term.php

示例4: connect

 public static function connect($host, $database, $user, $password)
 {
     if (!isset(self::$connection)) {
         $dsn = "mysql:host={$host};dbname={$database}";
         self::$connection = new PDO($dsn, $user, $password, self::$options);
     }
 }
開發者ID:vitabene,項目名稱:learn,代碼行數:7,代碼來源:Db.php

示例5: connect

 public static function connect($config)
 {
     self::$connection = @new mysqli($config['hostname'], $config['username'], $config['password'], $config['database']);
     if (self::$connection->connect_errno) {
         throw new Exception(self::$connection->connect_error);
     }
     self::execute("SET NAMES 'utf8'");
 }
開發者ID:joksnet,項目名稱:php-old,代碼行數:8,代碼來源:Db.php

示例6: connect

 public static function connect($host, $user, $password, $database)
 {
     if (!isset(self::$connection)) {
         self::$connection = @new PDO("mysql:host={$host};dbname={$database}", $user, $password, self::$settings);
         return true;
     }
     return false;
 }
開發者ID:ParalelniPolis,項目名稱:TMS2,代碼行數:8,代碼來源:Db.php

示例7: connect

 public function connect()
 {
     if (!isset(self::$connection)) {
         self::$connection = new mysqli('localhost', "root", "", "gotit");
     }
     if (self::$connection === false) {
         return false;
     }
     return self::$connection;
 }
開發者ID:nguyenanhdung83,項目名稱:test_gotit,代碼行數:10,代碼來源:Db.php

示例8: connect

 /**
  * Connect to the database
  *
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     if (!isset(self::$connection)) {
         $config = parse_ini_file('../config/config.ini');
         self::$connection = new mysqli($config['host'], $config['username'], $config['password'], $config['dbname']);
     }
     if (self::$connection === false) {
         return false;
     }
     return self::$connection;
 }
開發者ID:stevekrog,項目名稱:floraful,代碼行數:16,代碼來源:db.class.php

示例9: connect

 public function connect()
 {
     if (!isset(self::$connection)) {
         $login = $this->readLogin("../../config.json");
         self::$connection = new mysqli($login["hostname"], $login["username"], $login["password"], $login["db"]);
     }
     if (self::$connection->connect_errno) {
         echo "Failed to connect to MySQL: " . self::$connection->connect_error;
         return false;
     }
     return self::$connection;
 }
開發者ID:kenchan13579,項目名稱:CS160_web_mashup,代碼行數:12,代碼來源:Db.php

示例10: connect

 /**
  * Connect to database.
  */
 public static function connect()
 {
     self::$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD);
     if (!self::$connection) {
         trigger_error('Can\'t connect to database.');
         return false;
     } else {
         mysql_select_db(DB_DATABASE);
         mysql_query("SET CHARACTER SET " . MYSQL_CHARSET);
         return true;
     }
 }
開發者ID:notzen,項目名稱:ImpressPages-CMS,代碼行數:15,代碼來源:db.php

示例11: connect

 /**
  * Connect to the database
  * 
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     // Try and connect to the database
     if (!isset(self::$connection)) {
         self::$connection = new mysqli(global_mysql_server, global_mysql_user, global_mysql_password, global_mysql_database);
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     return self::$connection;
 }
開發者ID:kristijana,項目名稱:Administriranje,代碼行數:18,代碼來源:baza.php

示例12: connect

 public function connect()
 {
     if (!isset(self::$connection)) {
         self::$connection = new mysqli(\DbConfig::HOST, \DbConfig::USER_NAME, \DbConfig::USER_PASSWORD, \DbConfig::DB_NAME);
     }
     //If connection was not success, handle the error
     if (!self::$connection) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     self::$connection->autocommit(false);
     return self::$connection;
 }
開發者ID:pokakhoaitay,項目名稱:bedstore-angularjs,代碼行數:13,代碼來源:DB.php

示例13: connect

 /**
  * Connect to the database
  * 
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     // Try and connect to the database
     if (!isset(self::$connection)) {
         // Load configuration as an array. Use the actual location of your configuration file
         self::$connection = new mysqli('localhost', 'root', 'root', 'servicioslegales');
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     return self::$connection;
 }
開發者ID:JeysonMontenegro,項目名稱:ProyectoBases2,代碼行數:19,代碼來源:Conexion.php

示例14: connect

 /**
  * Connect to the database
  * 
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     // Try and connect to the database
     if (!isset(self::$connection)) {
         // Load configuration as an array. Use the actual location of your configuration file
         // Put the configuration file outside of the document root
         self::$connection = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME);
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     return self::$connection;
 }
開發者ID:sonaljain888,項目名稱:project-legal-lawyer-,代碼行數:20,代碼來源:class.Db.php

示例15: connect

 public function connect()
 {
     // Try and connect to the database, if a connection has not been established yet
     if (!isset(self::$connection)) {
         // Load configuration
         self::$connection = mysqli_connect(host, user, pass, dbname) or die("no connection");
         mysqli_select_db(self::$connection, 'moviefy');
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         //Handle Error - notify admin
         return mysqli_connect_error($connection);
     }
     return self::$connection;
 }
開發者ID:hyperlogin,項目名稱:moviefy,代碼行數:15,代碼來源:clsDatabase.php


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