private function getEscapedSortorder($name, $prefix = 'r')
{
$order = '';
$separatedOrders = $this->getOrderBys($name);
$totalOrderByElements = count($separatedOrders);
foreach ($separatedOrders as $index => $name) {
list($name, $asc) = $this->getSortOrder(trim($name));
// If we don't have a name, we can't determine a sortorder.
if (empty($name)) {
return false;
}
if (strpos($name, 'RAND') !== false) {
$order .= $name;
} elseif ($prefix !== false) {
$order .= $this->app['db']->quoteIdentifier($prefix . '.' . $name);
} else {
$order .= $this->app['db']->quoteIdentifier($name);
}
if (!$asc) {
$order .= ' DESC';
}
if ($this->isNotLastItemInArray($totalOrderByElements, $index)) {
$order .= ',';
}
}
return $order;
}