我试图找出 xPDO SQL 查询的排序顺序有什么问题,
这个查询
$criteria = $this->modx->newQuery($table);
$criteria->sortby($sortby,$sortdir);
$options = $this->modx->getCollectionGraph($table,$criteria);
$criteria->prepare();
echo '<pre>'.$criteria->toSQL().'</pre>';
导致这个 SQL ~ 这是正确的:
SELECT `Location`.`id` AS `Location_id`, `Location`.`created` AS `Location_created`,
`Location`.`modified` AS `Location_modified`, `Location`.`location` AS
`Location_location`, `Location`.`group` AS `Location_group`, `Location`.`comment`
AS `Location_comment`
FROM `flow_location` AS `Location` ORDER BY location asc
但是,如果我尝试循环查询:
foreach($options as $option) {
echo $option->get($value).'<br>';
}
它将通过数据库中的订单ID显示记录!?
我该如何解决?