activerecord and mysql differences? |
[eluser]andychurchill[/eluser]
$this->db->select('shows.url, shows.title as showTitle, shows.Description as showDescription, episodes.thumbnailImage'); $this->db->from('shows'); $this->db->join('episodes', 'episodes.show_id = shows.id'); $this->db->where('shows.genre_id', '(select genre_id from shows where url = \''.$show.'\')', false); $this->db->where('shows.url !=', $show); $query = $this->db->get(); echo $this->db->last_query(); using the above generates this: SELECT `shows`.`url`, `shows`.`title` as showTitle, `shows`.`Description` as showDescription, `episodes`.`thumbnailImage` FROM (`shows`) JOIN `episodes` ON `episodes`.`show_id` = `shows`.`id` WHERE shows.genre_id =(select genre_id from shows where url = 'some-other-programme') AND `shows`.`url` != 'some-other-programme' running this in MySQL Query Browser returns one row as expected, but CI seems to be returning 0 results? It's the same database, etc, nothing looks wrong, but it's just not working as I'd expect it to. Any ideas?
[eluser]Phil Sturgeon[/eluser]
Quote:1.) Output the final query and see if it looks right. Do this after your model call or within the model after $this->db->get(). Debugging ActiveRecord queries in CodeIgniter. |
Welcome Guest, Not a member yet? Register Sign In |