Hello!
I'm considering best practices in Phalcon when retrieving large datasets from the database. The built-in ORM functionality is amazing when you're just retrieving a couple of items and then getting their related records using the magical methods:
<?php
use \MyApp\Models\SupportTicket;
use \MyApp\Models\SupportTicketMessage;
use \MyApp\Models\Customer;
$tickets = SupportTicket::find(array("limit" => 10));
foreach ($tickets as $ticket) {
echo "Ticket " . $ticket->getId() . " was created my customer with email: " . $ticket->getCustomer()->getEmail() . ".\n";
}
However, I'm building a rest interface with models having 20+ related records, and if I want to use the built-in functionality as above to retrieve the items, I can get 1200+ DB questies for a single request.
I could use the QueryBuilder or a Resultset, but I'm unsure as of how to both fetch several records with relations AND get them as the Model objects in the PHP code.
Which is the best practice in this case?
Thanks for your time.
// dimhoLt