/**
  * Checks for 'ide' fields in the where clause and changes them into id fields
  * decrypts the values
  * @param   array   $where
  * @param   string  $table  scope of this where clause
  * @return  array
  */
 public function prepare_where($where, $table)
 {
     if (!is_array($where)) {
         return $where;
     }
     // looking for ides to map to ids with decrypt
     $pattern = '/\\b(?<field>[\\w.]*ide)\\s*=\\s*(?<ide>[\\w\']+)?/i';
     $find_matches = function ($str) use($pattern) {
         preg_match_all($pattern, trim($str), $matches);
         return $matches;
     };
     return array_map(function ($where) use($table, $find_matches) {
         $matches = $find_matches($where);
         $field = $matches['field'][0];
         if (empty($field)) {
             return $where;
         }
         $ide = str_replace("'", '', $matches['ide'][0]);
         $table_field = explode('.', $field);
         $field_name = $table_field[1] ?: $table_field[0];
         $tmp = aql2array::table_name_from_id_field($field_name);
         $table_name = $table_field[1] ? $tmp ?: $table_field[0] : ($tmp ?: $table);
         $id = decrypt($ide, $table_name);
         return preg_replace('/ide$/', 'id', $field) . ' = ' . $id;
     }, $where);
 }