Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Sometimes an object, sometimes and array
  • In my DB query with multiple relations, one of the relations is an object and the other is an array:

    $query = Model_Cards::query()
    ->related('sets')
    ->where($year)
    ->related('person')
    ->order_by(DB::expr('number+0'), 'asc');
    $cards = $query->get();

    Thanks
    Rich

  • And your question is?
  • Oops, Sorry - I think I had a hundred things going on when i wrote this.

    The questions is, why would the related 'sets' be available as:

    $cards->sets->name;

    and the related 'person' be available as:

    $cards->person['name']

    One is  an object and the other is an array.

    Thanks
    Rich
  • It is an object on a has_one/belongs_to, it is an array of objects if it is a has_many (or part of a many-many).

Howdy, Stranger!

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

In this Discussion