Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Nested set: how to get certain children?
  • I have some $page as Nested Set ORM object and I need to get certain children with condition WHERE `slug` = '<somevalue>'.

    How can I add this condition to children() method?

    Or use some another way?
  • Oh! It seems I've found the solution:



    	$page = $page
    ->children()
    ->build_query($page->tree_id)
    ->where('slug', '=', $segment)
    ->get_one();

    Ok. Thank you.
  • HarroHarro
    Accepted Answer
    Not sure what build_query() is doing there, it returns a new query object?

    $page->children()->where('slug', '=', $segment)->get();

    should return the subset of children of that page, with that slug.
  • Hmm.. It's really working! Thank you.

    But, my version is working too... and it does not work with roots(), so I decided with children() I need to set tree_id too. So I don't need to do that. That's nice :)

    Thank you.
  • Yours is probably working to because you just create a new query object. 

    But is isn't the way it was intended to be used. ;-)

Howdy, Stranger!

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

In this Discussion