Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Sometimes an object, sometimes and array
richtestani
February 2013
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
Harro
February 2013
And your question is?
richtestani
February 2013
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
Harro
February 2013
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).
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
February 2013
richtestani
February 2013