diff --git a/api/src/Storage/Base.php b/api/src/Storage/Base.php index 70aa354a4d..fcddaab0da 100644 --- a/api/src/Storage/Base.php +++ b/api/src/Storage/Base.php @@ -1190,6 +1190,10 @@ class Base /** * Return criteria array for a given search pattern * + * We handle quoted text, wildcards and boolean operators (+/-, AND/OR). If + * the pattern is '#' followed by an integer, the search is limited to just + * the primary key. + * * @param string $_pattern search pattern incl. * or ? as wildcard, if no wildcards used we append and prepend one! * @param string &$wildcard ='' on return wildcard char to use, if pattern does not already contain wildcards! * @param string &$op ='AND' on return boolean operation to use, if pattern does not start with ! we use OR else AND @@ -1218,6 +1222,11 @@ class Base $numeric_types = array('auto', 'int', 'float', 'double', 'decimal'); $numeric_columns = array(); + // Special handling for an ID search, # + if(strpos($_pattern, '#') === 0 && is_numeric(substr($_pattern, 1))) + { + return array('(' . $this->table_name.'.'. $this->autoinc_id . '=' . (int)substr($_pattern,1) . ')'); + } if(!$search_cols) { $search_cols = $this->get_default_search_columns(); diff --git a/infolog/inc/class.infolog_so.inc.php b/infolog/inc/class.infolog_so.inc.php index 3b36bd4d19..ed70781a65 100644 --- a/infolog/inc/class.infolog_so.inc.php +++ b/infolog/inc/class.infolog_so.inc.php @@ -886,6 +886,7 @@ class infolog_so $wildcard = $op = null; $so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db); + $so_sql->table_name = 'main'; $search = $so_sql->search2criteria($query['search'], $wildcard, $op, null, $columns); $sql_query = 'AND ('.(is_numeric($query['search']) ? 'main.info_id='.(int)$query['search'].' OR ' : ''). implode($op, $search) .')';