本文整理汇总了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 . " ]");
}
}
示例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;
}
示例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();