Sort assets by ID so matching '2' doesn't first match newer records

This commit is contained in:
Will Rossiter 2014-01-15 17:36:59 +13:00
parent caf1971c84
commit bd8e88e2ab

View File

@ -166,11 +166,13 @@ class DMSDocumentAddController extends LeftAndMain {
} }
public function documentautocomplete() { public function documentautocomplete() {
$term = $_GET['term']; $term = (isset($_GET['term'])) ? $_GET['term'] : '';
$term_sql = Convert::raw2sql($term); $term_sql = Convert::raw2sql($term);
$data = DMSDocument::get() $data = DMSDocument::get()
->where("(\"ID\" LIKE '%".$term_sql."%' OR \"Filename\" LIKE '%".$term_sql."%' OR \"Title\" LIKE '%".$term_sql."%')") ->where("(\"ID\" LIKE '%".$term_sql."%' OR \"Filename\" LIKE '%".$term_sql."%' OR \"Title\" LIKE '%".$term_sql."%')")
->sort('ID ASC')
->limit(20); ->limit(20);
$return = array(); $return = array();
foreach($data as $doc) { foreach($data as $doc) {
$return[] = array( $return[] = array(