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


PHP MySQLi::connect方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     @parent::connect(NAMESERVER, USERDB, PASSWDB, NAMEDB);
     if ($this->connect_errno) {
         throw new Exception(date('d/m/Y G:i:s T') . " Error#:" . $this->connect_errno . " [ " . $this->connect_error . " ]");
     }
 }
开发者ID:read424,项目名称:ssphcm,代码行数:7,代码来源:conexionbd.class.php

示例2: getDatabase

 /**
  * 数据库工厂方法
  */
 public static function getDatabase($id = 'master')
 {
     //读取数据库配置文件
     if ($id == 'master') {
         $db_conf = Init::getInstance()->config['DataBase']['master'];
     } else {
         $db_conf = Init::getInstance()->config['DataBase']['slave'];
     }
     $key = 'database_' . $id;
     //获取数据库对象
     $db = Register::get($key);
     if (!$db) {
         $db = new MySQLi();
         $db->connect($db_conf['host'], $db_conf['user'], $db_conf['password'], $db_conf['dbname']);
         Register::set($key, $db);
     }
     return $db;
 }
开发者ID:xxlixin1993,项目名称:Frame,代码行数:21,代码来源:Factory.class.php

示例3: foreach

    foreach ($values as $value) {
        $tvalues[] = make_mysql_values($value, $mysql);
    }
    $values = implode($tvalues, ",\n");
    $dup = '';
    foreach ($okeys as $index => $key) {
        $dup .= "{$key}=VALUES({$key})";
        if ($index < count($okeys) - 1) {
            $dup .= ',';
        }
    }
    $query = "INSERT INTO {$table} {$keys} VALUES {$values} ON DUPLICATE KEY UPDATE {$dup};";
    $mysql->query($query) or die($table . ': ' . $mysql->error . "\n" . $query);
}
$mysql = new MySQLi();
$mysql->connect('localhost', 'root', 'root', 'cap');
print "Ripping CAP Database...\n";
$makes = array('volkswagen', 'audi', 'skoda', 'ford');
foreach ($makes as $make) {
    $started = strtotime('now');
    print "(" . date('d-m-Y H:i:s') . ") Getting all ranges and derivatives for the {$make} manufactuerer\n";
    $make = make_load($make);
    $ranges = get_vehicle('GetCAPRange', 'gvranges_' . $make->CMan_Name, array('ManCode' => (string) $make->CMan_Code, 'JustCurrentRanges' => 'true', 'BodyStyleFilter' => ''));
    foreach ($ranges as $range) {
        $derivatives = get_vehicle('GetCAPDerFromRange', 'gv_der_' . $range->CRan_Code, array('RanCode' => (string) $range->CRan_Code, 'JustCurrentDerivatives' => true, 'BodyStyleFilter' => ''));
        print "Updating " . count($derivatives) . " derivatives.\n";
        store_xml_array($derivatives, 'derivatives', $mysql, array('id', 'CRan_Code'), array(null, $range->CRan_Code));
        foreach ($derivatives as $der) {
            $bundle = get_nvd('GetCAPOptionsBundle', 'gv_opts_' . $der->CDer_ID, array('CAPID' => (string) $der->CDer_ID, 'OptionDate' => '2010-01-01', 'JustCurrent' => 'true', 'DescriptionRS' => 'true', 'OptionsRS' => 'true', 'RelationshipsRS' => 'true', 'PackRS' => 'true', 'TechnicalRS' => 'true'));
            $bun = array();
            $arr = array();
开发者ID:haxd,项目名称:cap-drupal,代码行数:31,代码来源:caprip.php


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