Reputation: 47
So, I am trying to get the IMDb id for the from the table called videos. I tried it with these these are giving me error. Code 1:
$imdb_id = $this->db->get_where('videos', array('imdbid'))->result_array();
Code 2:
$imdb_id = $this->db->get('videos','imdbid');
code 3:
$query = $this->db->query("SELECT * FROM videos;");
$row = $query->row(0, 'videos');
$imdb_id = $row['imdbid'];
Here is a screenshot of database table. Thank you for your contribution in advance.
Upvotes: 0
Views: 61
Reputation: 88
Please explain the error and output expectations.
you want only one return data or multiple data?
This Codeigniter 3 right?
the current code you are using is incorrect :
Code 1 :
// will get only one data with where condition
// videos_id = 1
$video_id = 1;
$data = $this->db->get_where('videos', array('videos_id'=>$video_id))->result_array();
$imdb_id = $data[0]['imdbid'];
Code 2 :
// will get all data without where condition
// must use loop foreach
$data = $this->db->get('videos')->result_array();
Upvotes: 1