Hi,
How can I order records that I get by get_linked_beans?
Thanks!
Hi,
How can I order records that I get by get_linked_beans?
Thanks!
Hi,
usort($contacts, function($a, $b)
{
return strcmp($a->fieldA, $b->fieldA);
});
Thank u
My solution is:
$beanParent->load_relationship('beanChild_relationship');
$beanChildIdArr = $beanParent->beanChild_relationship->get();
$beanChildIdStr = "'".implode("','",$beanChildIdArr)."'";
$beansChild = BeanFactory::getBean('beanChild')
->get_full_list(
//Order by
'field_name DESC',
//Where
"beanChild.id in ($beanChildIdStr)"
);
Hi,
in the past i have try your solution and i have no result of sort (maybe a bug is now resolved.)
Regards
Hm, it works for me.
The idia is get all child ids to array ($beanParent->beanChild_relationship->get()
Then convert that array to string like ‘id1’,‘id2’ and then get all related records by method get_full_list (it has order_by function)