Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Counting Items within a Relation
  • I would like to be able to count results for each relation within an ORM result. Take the following code for instance <code>
    $allContexts = Model_Context::find('all', array(
    'where' => array('typeID' => $projectType)
    )); $contextsToDisplay = array(); foreach($allContexts as $context){
    if(count($context->messages) >= 1) {
    $contextsToDisplay[] = $context;
    </code> Is there an easier way to do this? Perhaps a way to return the number of results for each relation? In the example above, I am only displaying messages. However, for the project I am working on, we also have tasks, notes, screenshots, et cetera. If anyone has any suggestions, that would be helpful. I hope I am explaining myself well enough. Thanks!

Howdy, Stranger!

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