mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
fixed %by
This commit is contained in:
@@ -245,21 +245,23 @@ abstract class DibiTable extends DibiObject
|
|||||||
/**
|
/**
|
||||||
* Selects all rows.
|
* Selects all rows.
|
||||||
* @param array conditions
|
* @param array conditions
|
||||||
* @param string column to order by
|
* @param string|array column to order by
|
||||||
* @return DibiResult
|
* @return DibiResult
|
||||||
*/
|
*/
|
||||||
public function findAll($conditions = NULL, $order = NULL)
|
public function findAll($conditions = NULL, $order = NULL)
|
||||||
{
|
{
|
||||||
|
if (!is_array($order)) {
|
||||||
$order = func_get_args();
|
$order = func_get_args();
|
||||||
if (is_array($conditions)) {
|
if (is_array($conditions)) {
|
||||||
array_shift($order);
|
array_shift($order);
|
||||||
} else {
|
} else {
|
||||||
$conditions = NULL;
|
$conditions = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $this->complete($this->connection->query(
|
return $this->complete($this->connection->query(
|
||||||
'SELECT * FROM %n', $this->name,
|
'SELECT * FROM %n', $this->name,
|
||||||
'%ex', $conditions ? array('WHERE %and', $conditions) : NULL,
|
'%ex', $conditions ? array('WHERE %and', $conditions) : NULL,
|
||||||
'%ex', $order ? array('ORDER BY %n', $order) : NULL
|
'%ex', $order ? array('ORDER BY %by', $order) : NULL
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -249,8 +249,12 @@ final class DibiTranslator extends DibiObject
|
|||||||
|
|
||||||
case 'by': // key ASC, key DESC
|
case 'by': // key ASC, key DESC
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
|
if (is_string($k)) {
|
||||||
$v = (is_string($v) && strcasecmp($v, 'desc')) || $v > 0 ? 'ASC' : 'DESC';
|
$v = (is_string($v) && strcasecmp($v, 'desc')) || $v > 0 ? 'ASC' : 'DESC';
|
||||||
$vx[] = $this->delimite($k) . ' ' . $v;
|
$vx[] = $this->delimite($k) . ' ' . $v;
|
||||||
|
} else {
|
||||||
|
$vx[] = $this->delimite($v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return implode(', ', $vx);
|
return implode(', ', $vx);
|
||||||
|
|
||||||
@@ -306,6 +310,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
case 't': // datetime
|
case 't': // datetime
|
||||||
return $this->driver->escape(is_string($value) ? strtotime($value) : $value, $modifier);
|
return $this->driver->escape(is_string($value) ? strtotime($value) : $value, $modifier);
|
||||||
|
|
||||||
|
case 'by':
|
||||||
case 'n': // identifier name
|
case 'n': // identifier name
|
||||||
return $this->delimite($value);
|
return $this->delimite($value);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user