当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli::connect方法代码示例

本文整理汇总了PHP中mysqli::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::connect方法的具体用法?PHP mysqli::connect怎么用?PHP mysqli::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli的用法示例。


在下文中一共展示了mysqli::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Connect
  * @param string $host
  * @param string $user
  * @param string $paswd
  * @param string $db
  * @param int $port
  * @return mixed
  */
 public function connect($host, $user, $paswd, $db, $port = self::DEFAULT_PORT)
 {
     $port = (int) $port;
     $res = @$this->conn->connect($host, $user, $paswd, $db, $port);
     if (0 !== mysqli_connect_errno($this->conn)) {
         throw new Mage_DB_Exception(mysqli_connect_error($this->conn));
     }
     return $res;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:18,代码来源:Mysqli.php

示例2: connect

 public function connect($host = "92.222.29.95", $user = "iwebRayane", $paswd = "CestLeProjet2.0", $db = "projetiweb")
 {
     //$port = (int) $port;
     $res = @$this->conn->connect($host, $user, $paswd, $db, 3306);
     if (0 !== mysqli_connect_errno($this->conn)) {
         //throw new mysqli_connect_error($this->conn);
         echo 'Erreur de connection<br>';
         print_r(error_get_last());
         echo "<br>" . mysqli_connect_errno($this->conn) . ": " . mysqli_connect_error($this->conn) . "<br>" . $this->conn->connect_errno . " | " . $this->conn->connect_error;
     }
     return $res;
 }
开发者ID:Sup-Galilee-AIR-2014-2017,项目名称:Teacher-Research_Project,代码行数:12,代码来源:Manager_base.php

示例3: connect

 /**
  * 参数为了兼容parent类,代码不会使用传入的参数作为配置
  * @param null $_host
  * @param null $user
  * @param null $password
  * @param null $database
  * @param null $port
  * @param null $socket
  * @return bool
  */
 function connect($_host = null, $user = null, $password = null, $database = null, $port = null, $socket = null)
 {
     $db_config =& $this->config;
     $host = $db_config['host'];
     if (!empty($db_config['persistent'])) {
         $host = 'p:' . $host;
     }
     if (isset($db_config['passwd'])) {
         $db_config['password'] = $db_config['passwd'];
     }
     if (isset($db_config['dbname'])) {
         $db_config['name'] = $db_config['dbname'];
     } elseif (isset($db_config['database'])) {
         $db_config['name'] = $db_config['database'];
     }
     parent::connect($host, $db_config['user'], $db_config['password'], $db_config['name'], $db_config['port']);
     if ($this->connect_errno) {
         trigger_error("mysqli connect to server[{$host}:{$db_config['port']}] failed: " . mysqli_connect_error(), E_USER_WARNING);
         return false;
     }
     if (!empty($db_config['charset'])) {
         $this->set_charset($db_config['charset']);
     }
     return true;
 }
开发者ID:matyhtf,项目名称:swoole_framework,代码行数:35,代码来源:MySQLi.php

示例4: connect

 public function connect($host = NULL, $user = NULL, $password = NULL, $database = NULL, $port = NULL, $socket = NULL)
 {
     $config = $this->config;
     if ($config['host'] === 'localhost') {
         @parent::connect($config['host'], $config['user'], $config['password'], $config['database'], 0, $config['socket']);
     } else {
         @parent::connect($config['host'], $config['user'], $config['password'], $config['database'], $config['port']);
     }
     if ($this->connect_errno) {
         Log::prn_log(ERROR, "database connect failed: " . $this->connect_error . "!");
         return false;
     }
     Log::prn_log(INFO, "database connect ok ({$config['host']},{$config['port']})!");
     if (isset($config['charset'])) {
         Log::prn_log(INFO, "set charset names {$config['charset']}");
         $this->query("set names {$config['charset']}");
     }
     if (isset($config['sqls'])) {
         $sqls = explode(";", $config['sqls']);
         foreach ($sqls as $sql) {
             Log::prn_log(INFO, "{$sql}");
             $this->query($sql);
         }
     }
     return true;
 }
开发者ID:loder,项目名称:asf,代码行数:26,代码来源:mysql.php

示例5: dbConnect

function dbConnect()
{
    //Connessione DB
    $mysqli = new mysqli();
    $mysqli->connect(_DB_SERVER, _DB_USER, _DB_PASSWORD, _DB_NAME);
    return $mysqli;
}
开发者ID:alessiobusonera,项目名称:amm2015,代码行数:7,代码来源:php_functions.php

示例6: __construct

 private function __construct()
 {
     $this->ccnn = parent::connect($this->host, $this->user, $this->pass, $this->ddbb);
     if ($this->connect_errno) {
         die('Error # ' . $this->connect_errno . ': ' . $this->connect_error);
     }
 }
开发者ID:Cristian9,项目名称:AdobeConnect,代码行数:7,代码来源:accdb.php

示例7: connect

 function connect()
 {
     $db_config =& $this->config;
     parent::connect($db_config['host'], $db_config['user'], $db_config['password'], $db_config['dbname']);
     if (mysqli_connect_errno()) {
         exit("Connect failed: %s\n" . mysqli_connect_error());
     }
     $this->set_charset($db_config['charset']);
 }
开发者ID:superwmh,项目名称:swoole,代码行数:9,代码来源:MySQL2.class.php

示例8: initializeDbConnection

 /**
  * get database connection infos and connect to the database
  *
  * @return mysqli
  */
 public static function initializeDbConnection()
 {
     $dbPath = config_get('hostname');
     $dbUser = config_get('db_username');
     $dbPass = config_get('db_password');
     $dbName = config_get('database_name');
     $mysqli = new mysqli($dbPath, $dbUser, $dbPass, $dbName);
     $mysqli->connect($dbPath, $dbUser, $dbPass, $dbName);
     return $mysqli;
 }
开发者ID:Cre-ator,项目名称:Whiteboard.Menu-Plugin,代码行数:15,代码来源:wmApi.php

示例9: createConnection

 /**
  * create mysql connection
  */
 protected function createConnection()
 {
     $config = $this->config;
     $db = new \mysqli();
     $db->connect($config['host'], $config['user'], $config['password'], $config['database'], $config['port']);
     $db_sock = swoole_get_mysqli_sock($db);
     swoole_event_add($db_sock, array($this, 'onSQLReady'));
     $this->idle_pool[] = array('object' => $db, 'socket' => $db_sock);
     $this->connection_num++;
 }
开发者ID:silentred,项目名称:learning-path,代码行数:13,代码来源:MySQL.php

示例10: connectDb

 /**
  * Restituisce una connessione funzionante al db
  * @return \mysqli una connessione funzionante al db dell'applicazione,
  * null in caso di errore
  */
 public function connectDb()
 {
     $mysqli = new mysqli();
     $mysqli->connect(Settings::$db_host, Settings::$db_user, Settings::$db_password, Settings::$db_name);
     if ($mysqli->errno != 0) {
         return null;
     } else {
         return $mysqli;
     }
 }
开发者ID:nadiajolanda,项目名称:esAMM2014,代码行数:15,代码来源:Db.php

示例11: ConGestionDC

function ConGestionDC()
{
    try {
        $con = new mysqli();
        $con->connect('localhost', 'root', '', 'gestiondc');
        return $con;
    } catch (Exception $ex) {
        return "Error: " . $ex->getMessage();
    }
}
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:10,代码来源:conexiones.php

示例12: connect

 public function connect($host = null, $user = null, $psw = null, $dbname = null, $port = null, $socket = null, $tbname = null)
 {
     parent::connect($host, $user, $psw, $dbname, $port, $socket);
     $host != null && ($this->_host = $host);
     $port != null && ($this->_port = $port);
     $user != null && ($this->_user = $user);
     $psw != null && ($this->_psw = $psw);
     $dbname != null && ($this->_dbname = $dbname);
     $tbname != null && ($this->_tbname = $tbname);
     $socket != null && ($this->_socket = $socket);
 }
开发者ID:renwuxun,项目名称:core,代码行数:11,代码来源:MysqliConn.php

示例13: f

 public static function f($connection)
 {
     list($host, $user, $pass, $db) = explode(':', $connection);
     if (empty(self::$instance_f[$connection])) {
         $i = new mysqli();
         $i->connect($host, $user, $pass, $db, true);
         self::$instance_f[$connection] = $i;
         return $i;
     } else {
         return self::$instance_f[$connection];
     }
 }
开发者ID:Git-Host,项目名称:sms,代码行数:12,代码来源:mysqli.class.php

示例14: onStart

 function onStart($serv)
 {
     $this->serv = $serv;
     for ($i = 0; $i < $this->pool_size; $i++) {
         $db = new mysqli();
         $db->connect('172.16.1.19', 'test', 'test', '1188test');
         $db_sock = swoole_get_mysqli_sock($db);
         swoole_event_add($db_sock, array($this, 'onSQLReady'));
         $this->idle_pool[] = array('mysqli' => $db, 'db_sock' => $db_sock, 'fd' => 0);
     }
     echo "Server: start.Swoole version is [" . SWOOLE_VERSION . "]\n";
 }
开发者ID:silentred,项目名称:learning-path,代码行数:12,代码来源:mysql_proxy_server.php

示例15: connect

 function connect()
 {
     $db_config =& $this->config;
     parent::connect($db_config['host'], $db_config['user'], $db_config['passwd'], $db_config['name']);
     if (mysqli_connect_errno()) {
         trigger_error("Mysqli connect failed: %s\n" . mysqli_connect_error());
         return false;
     }
     if (!empty($db_config['charset'])) {
         $this->set_charset($db_config['charset']);
     }
     return true;
 }
开发者ID:jinguanio,项目名称:swoole_websocket,代码行数:13,代码来源:MySQLi.php


注:本文中的mysqli::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。