How to get all the relations of each bean?

35 views
Skip to first unread message

sap...@gmail.com

unread,
Aug 8, 2017, 12:22:24 PM8/8/17
to redbeanphp
hi, im new to red bean and im not sure if there is an easy way to get all the relations (or x relations), right now the only way i found is:

$localidades = $this->db::findAll('localidad', 'ORDER BY nombre ASC');

foreach($localidades as $localidad)
{
    $localidad->municipio->nombre;
}

If i dont do that i cant get $localidad->municipio->nombre in my template >_o, i know thats a mess, thats why i want some advice :(

localidad have id, name, municipio_id
municipio have id, name

thanks n_nU

Didier Boka

unread,
Oct 26, 2017, 2:54:52 PM10/26/17
to redbeanphp
I Diego !

Do that.

$localidades = $this->db::findAll('localidad', 'ORDER BY nombre ASC')->export();

foreach($localidades as $localidad)
{
    $localidad->municipio->nombre;
}
Reply all
Reply to author
Forward
0 new messages