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