L
L
Lone Ice2018-01-30 18:24:01
Kohana
Lone Ice, 2018-01-30 18:24:01

How to get current element in ORM?

I'm working on a site written in Kohana that uses an ORM. The task was to display the current element of the array (as I thought), of course current () did not work, then I printed the object and ...

$allPhotos=ORM::factory('Images')->where('id_restoran', '=', $restoran->id)->order_by('id')->find_all();
var_dump($allPhotos);
foreach ($allPhotos as $value){
    var_dump($value);
}

... saw horror (for myself). Not only does $allPhotos return an object with protected properties, but also each element contains the same, and the necessary fields, for example $value->id, are in the protected _object property, but this "something" can be easily displayed through foreach.
Therefore questions:
1. What is this crap???
2. How to display the current photo (essentially the current element of the array, as always it was like)?
3. What to read about ORM, so as not to ask such questions? (but for me this is a discovery, honestly)
UPD . Everything turned out to be simple - $allPhotos[0] and $allPhotos[0]->id... Why then so many protected properties, why store a bunch of properties in each element, and in addition also fields from the database, I don’t I see...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-01-30
@SAnhPa

kohanaframework.su/database/orm_basics_select

foreach ($allPhotos as $photo){
    $photo->field_name;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question