php - Object sort order is wrong -
i'm trying figure out wrong sort order on xpdo sql query,
this query
$criteria = $this->modx->newquery($table); $criteria->sortby($sortby,$sortdir); $options = $this->modx->getcollectiongraph($table,$criteria); $criteria->prepare(); echo '<pre>'.$criteria->tosql().'</pre>'; results in sql ~ correct:
select `location`.`id` `location_id`, `location`.`created` `location_created`, `location`.`modified` `location_modified`, `location`.`location` `location_location`, `location`.`group` `location_group`, `location`.`comment` `location_comment` `flow_location` `location` order location asc however, if try loop on query:
foreach($options $option) { echo $option->get($value).'<br>'; } it display records order id in database!?
how fix that?
you ordering location asc, location not defined in query. rename column location location_location, should order location_location asc.
select `location`.`id` `location_id`, `location`.`created` `location_created`, `location`.`modified` `location_modified`, `location`.`location` `location_location`, `location`.`group` `location_group`, `location`.`comment` `location_comment` `flow_location` `location` order location asc
Comments
Post a Comment