Thanks for the reply,
That being the case, I am pleasantly surprised that despite the
documentation making a big play on how different the new ORM is, I can (if
I choose) create my queries in much the same way.
The example I posted was a effectively a find 'all' (paginated using a
limit clause). What about a find first, is this still as straightforward?
Here is an example from the same controller, how would that translate
please?
$options = array(
'conditions' => array(
'Rental.id' => $id,
),
'contain' => array(
'Trailer' => array(
'fields' => array('id', 'number', 'make', 'year'
, 'license', 'vin', 'skirt')
),
'Lessee' => array(
'fields' => array('id', 'account', 'name',
'address_1', 'address_2', 'city', 'state', 'zip_1', 'zip_2')
)
)
);
$this->request->data = $this->Rental->find('first', $options);
Dave
On Tuesday, 24 March 2015 13:04:21 UTC, Dave Edwards wrote:
>
> Here is a sample of some code I use in a Trailer rental application. This
> is a method from the Rental Controller.
>
> Rental hasMany Trailers and hasMany Lessees
>
> public function archived($id = null) {
>
>
> $options = array(
> 'limit' => 10,
> 'order' => 'Trailer.number ASC',
> 'fields' => array('id', 'trailer_id', 'lessee_id', 'date_out',
> 'rented', 'agreement_number'),
> 'conditions' => array(
> 'Rental.deleted' => '1',
> ),
> 'contain' => array(
> 'Trailer' => array(
> 'fields' => array('id', 'number', 'make', 'license'),
> ),
> 'Lessee' => array(
> 'fields' => array('id', 'account', 'name'),
> )
> )
> );
>
>
> $this->paginate = $options;
> $this->set('rentals', $this->paginate());
> }
>
>
> Turning off recursive, and using Containable provides a very flexible and
> readable method of building a query. Adding conditions, fields, associated
> models etc is a snip. Whoever produced this method of working should be
> fully credited.
>
> My question is, how would something like this be created in CakePHP 3?
> There seem to be many many more pages to read and understand regarding the
> new ORM, and I'm really unsure how simple it will be to convert. Will I be
> able to achieve it in the a similar manner, and will it be as readable, and
> easy to edit?
>
> Are there any examples in the new Manual (I can't find any), where the new
> ORM is used to bring all the new methods of working together in much the
> same way as the method above?
>
> Thanks
>
> Dave
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.