これじゃ頭が回らない…
コントローラ:
public function update()
{
$string = 'xml/gzip';
$xml = simplexml_load_file("compress.zlib://$string");
foreach ($xml->merchant as $merchant) {
$merchant_name = $merchant['name'];
$merchant_id = $merchant['id'];
$data1 = array(
'merchant_id' => $merchant_id,
'merchant_name' => $merchant_name
);
$this->load->model('Administration_model');
$this->Administration_model->insert_merchants($data1);
}
}
モデル:
public function insert_merchants($data1)
{
$this->db->insert('merchants', $data1);
}
私のコントローラーのforeach
ループは、xml スプレッドシートからデータを実行しています。エラーが示すように、値 '911' と 'website.com' は挿入された値である必要があります...では、なぜ 'website.com' を'フィールドリスト'?
エラー:
A Database Error Occurred
Error Number: 1054
Unknown column 'website.com' in 'field list'
INSERT INTO `merchants` (`merchant_id`, `merchant_name`) VALUES (911, website.com)
それがプライマリ列であり、これが技術的に重複したエントリであるという事実と関係merchant_id
がありますか...もしそうなら、「ON DUPLICATE KEY ...」機能を追加する方法に関するヒントはありますか?