[eluser]w1n78[/eluser]
i'm trying to update a table with values from an array.
controller
Code:
class Collection_controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('collection_model');
$this->load->library('amazon_api_class');
$this->auth_library->check_auth('admin, user');
$this->output->enable_profiler(TRUE);
}
public function detail()
{
$this->load->model('movie_model');
// update movie record
$this->collection_model->update_movie($this->uri->segment(3), FALSE);
$data['page_title'] = 'Collection Detail';
$data['results'] = $this->collection_model->get_one($this->uri->segment(3));
$this->load->view('templates/header', $data);
$this->load->view('collection/detail', $data);
$this->load->view('templates/footer');
}
}
model
Code:
class Collection_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function update_movie($asin, $check_time = TRUE)
{
$results = $this->common_library->parse_amazon_data($this->amazon_api_class->getItemByAsin($asin));
$this->title = $results[0]["title"];
$this->db->set('title', $this->title);
$this->db->where('asin', $asin);
$this->db->update('movie');
}
}
here's the error
Code:
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Street: Preschool Is Cool! ABCs with Elmo WHERE `asin` = 'B003ITZBV8'' at line 1
UPDATE `movie` SET `title` = Sesame Street: Preschool Is Cool! ABCs with Elmo WHERE `asin` = 'B003ITZBV8'
i don't know why it's not wrapping the value in quotes. i've also tried $db->escape() and $db->escape_str(). the update values are from an array.
what am i doing wrong? did i miss something?