[dev] Horde RDO: retrieve sorted
Ralf Lang
lang at b1-systems.de
Thu Feb 15 15:05:45 UTC 2018
Am 15.02.2018 um 15:39 schrieb Sebastian Birnbach:
> I have a ONE:MANY relationship between data types A and B. With Horde RDO
> accessing a B from a given A is as easy as A->B[i].
>
> When there are several B elements I would like them to come in a
> predetermined order. For instance, elements B might each have an element x
> and A->B could return the collection of elements B sorted by x in
> descending order:
>
> A->B[0]->x > A->B[1]->x > A->B[2]->x ...
>
> It is clear that the sorting could be accomplished through the right SQL
> statements. Can RDO be persuaded to do this for me?
>
Hallo Sven,
For searches, you can add a sortBy clause either in the mapper or in the
Rdo_Query object. For relations, I think it is not yet implemented.
You can of course implement the relation in the item object to mimic this
FooItem extends Horde_RdoBase
{
function getBars()
{
$bm = $this->mapper->factory->create('BarMapper')
$query = new Horde_Rdo_Query($bm);
$query->sortBy("SomeBarProp ASC")
$query->addTest(foo_id, "=", $this->foo_id);
$bars = $bm->find($query);
return $bars
}
Because of magic methods, it will look like the same thing:
$bars = $myFoo->bars;
typeof bars Horde_Rdo_List, containing FooItems
This is written from memory, function signatures and SQL details may
differ. I think it makes sense to add a feature request.
However, iirc, eager relations are implemented as joins while lazy
relations are essentially an automated way to implement the above. So we
would need two implementations for this.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
More information about the dev
mailing list