Change $where = array() to use IN clause
trying to change the $where expression to IN rather than = operator.
$where = array('blog_categories.id' => 1, 'blog_categories.id' => 2, 'blog_categories.id' => 3);
as
$categoryIds = array(1, 2, 3);
$where => array('blog_categories.id' => $categoryIds, 'blog_posts.published' => 'yes')
Can someone point me to the correct way using the get_posts_by_page() within Fuel_blog.php?
Comments
$this->blog_posts_model->where_in('fuel_blog_categories.id', $categoryIds); $this->fuel_blog-> get_posts_by_page();
Fuel_blog is just a wrapper around the different models (e.g. posts, categories, links etc). You can always just use the model directly if you need something else not provided by Fuel_blog.
$where = array('blog_categories.id' => 1, 'blog_categories.id' => 2);
from
`blog_categories`.`id` = 1 AND `blog_categories`.`id` = 2
to
`blog_categories`.`id` = 1 OR `blog_categories`.`id` = 2
http://codeigniter.com/user_guide/database/active_record.html
I tried to use 'where_not_in' and recieved the following error: (using v 0.9.3)
PHP Fatal error: Uncaught exception 'Exception' with message 'Method where_not_in does not exist.' in application/core/MY_Model.php:2322
// use the Navigation model from the FUEL admin panel to identify $CI =& get_instance(); $CI->load->module_model(FUEL_FOLDER, 'navigation_model'); // #TODO: this should be made to look better, with option groups $where = array('parent_id' => 0); $CI->navigation_model->where_not_in('location', array('home','account','plan')); $nav_options = $CI->navigation_model->options_list('id','label',$where);
the query I want to generate is:
select id,label from fuel_navigation where parent_id = 0 and location not in ('home', 'account', 'plan');
Changing to:
$CI->navigation_model->db->where_not_in('location', array('home','account','plan'));
Stops the error, but has no effect on the query ran by options list.
Another approach that does work:
$nav_options = $this->navigation_model->options_list('id','label', 'parent_id = 0 AND location NOT IN ("home", "account", "plan")');