[eluser]bee27[/eluser]
Hi,
I'm relatively new to CodeIgniter and DMZ, but have come across a strange issue, and I'm not sure if its me or a bug...
I have models Site and Page. Site can have many Pages, and Pages can have one Site. The pages table has the site_id, rather than a joining table.
I run the following code, to get the first page for the site...
Code:
$page = $s->page->where('order', 0)->where('visible', 1)->get();
and the SQL is ...
Code:
SELECT `pages`.*
FROM (`pages`)
WHERE (
`pages`.`order` = 0
AND `pages`.`visible` = 1
)
AND
`pages`.`site_id` = 4
... which is correct.
Then I do the following, to get all pages for the site (to build a navigation list) ...
Code:
$pages = $s->page->where('visible', 1)->get();
... and the SQL is ...
Code:
SELECT *
FROM (`pages`)
WHERE `pages`.`visible` = 1
... the where clause for the site_id seems to be missing, so all pages for all sites get returned!
Am I doing something wrong, do I need to reset something before running the 2nd query? Strangely if I swap the order of the two calls the 2nd always misses out the site_id where clause.
Thanks for any help!