/** * Parses the where clause and adds the table name to fields that do not have it * @param mixed $array * @param string $table * @return mixed */ public function check_where($array, $table = '') { if (!$table || !is_array($array)) { return $array; } foreach ($array as $k => $where) { if (preg_match('/(?:case\\s+when)' . self::$not_in_quotes . '/mi', $where)) { $array[$k] = aql2array::parse_case_when($where, $table); } else { $pattern = '/([()]*[\'%\\w\\/.#!@$%^&*\\\\{\\}]+[()]*)' . self::$not_in_quotes . '/mi'; $callback = function ($m) use($table) { return aql2array::add_table_name($table, $m[1]); }; $n = preg_replace_callback($pattern, $callback, $where); $array[$k] = self::put_back_escaped_quotes($n); } } return $array; }