Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How do you do slightly more complex queries with ORM?
  • Hi guys, This is a reasonably straightforward SQL query that I'm trying to get running with ORM, but no luck....
    SELECT * FROM `nodes` WHERE `status` = 'published' AND (`nodetype_id` = 1 OR `nodetype_id` = 3 OR `nodetype_id` = 4)
    ORDER BY published_at DESC LIMIT 14
    Would any of you know how to do this?
    This is where I'm at.... $nodes = Model_Node::find('all', array(
    'where' => array(
    array('status', '=', 'published'),
    array('nodetype_id', '=', 1), //<--- Get lost here...
    ),
    'order_by' => array('published_at' => 'desc'),
    'limit' => 14,
    ));
    Thanks in advance, Leonard
  • guess this'll work ... $allowed_nodetype_ids = array(1,3,4);
    $nodes = Model_Node::find()->where('status', 'published')->where('nodetype_id', 'in', $allowed_nodetype_ids)->order_by('date', 'desc')->limit(14)->get();

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion