Ejemplo n.º 1
0
 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 . " ]");
     }
 }
Ejemplo n.º 2
0
 /**
  * 数据库工厂方法
  */
 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;
 }
Ejemplo n.º 3
0
    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();