Pythontr

husonet | Tarih: 14.05.2012

Php Codeigniter Order By Field function

Codeigniter OrderBy Field Function düzenlemesi order by a where_in() query

vim sistem/database/DB_active_rec.php

	/**
* Order By Field
*
* Order By Field allows you to specify the order
* of an MySQL result - useful if you want to
* order by a where_in() query.
*
* @param string $row
* @param array/string $values
* @return object
*/
function order_by_field($row, $values) {
/* Clean the row */
$row = $this->_protect_identifiers($row);

/* Clean and implode the values */
if(is_array($values)) {
foreach($values as $key => $value) {
$values[$key] = $this->escape($value);
}
$values = implode(',', $values);
} else {
$values = $this->escape($value);
}

/* Build the query */
$query = "FIELD({$row}, {$values})";

$this->ar_orderby[] = $query;
return $this;
}