Trying to insert an array with the help of CodeIgniter Active reacords. Table has just two columns id(autoincrement pk column)
and value
.
$data array I am populating from Google Contact API response. Here how I am populating array $data in controller and passing it to model
$val = $client->getIo()->authenticatedRequest($req);//Getting response from Google Contact API.
$xml = simplexml_load_string($val->getResponseBody());
$result = $xml->xpath('//gd:email'); //Fetching email addressed from the response
foreach ($result as $title) {
array_push($gmailContacts, mysql_real_escape_string($title->attributes()->address));
}
$this->load->model('gmailContacts');
$this->gmailContacts->saveContacts($gmailContacts);
Model Code is
function saveGmailContacts($data=array())
{
$this->db->insert('contact_table',$data);
}
Error is
Error Number: 1054
Unknown column '0' in 'field list'
INSERT INTO `importedgmailcontacts` (`0`, `1`, `2`, `3`, `4`, `5`)VALUES ('VALUE1', 'VALUE2', 'VALUE3','VALUE4', 'VALUE5')
I am using Codeigniter with XAMPP 1.7.7 which has PHP 5.3.3 and MySql 5.0