Skip to content

Sorting a field within relation #56

@thipages

Description

@thipages

Hi,

lets have a table A which has a fk a_bId refrencing table B, B containg a field b_field
I want to retrieve all A records sorted by b_field.
$sortingString="b_field"; is not working (see $sortingString below).
How may I manage it?
Thank you

$mapperA= new \Maphper\Maphper(
    new \Maphper\DataSource\Database($pdo, 'A', 'id')
);
$mapperB= new \Maphper\Maphper(
    new \Maphper\DataSource\Database($pdo, 'B', 'id')
);
$mapperA->addRelation("b", new\Maphper\Relation\One($mapperB,"a_bId","id"));

$sortingString="what may I put here?";
foreach ($mapperA->sort($sortingString) as $A) {
  echo ($A->b->b_field.":".$A->name);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions