示例#1
0
 /**
  * Prepares the query criteria or new document object.
  *
  * PHP field names and types will be converted to those used by Riak.
  *
  * @param array $query
  * @return array
  */
 public function prepareQueryOrNewObj(array $query)
 {
     $preparedQuery = array();
     foreach ($query as $key => $value) {
         // Recursively prepare logical query clauses
         if (in_array($key, array('$and', '$or', '$nor')) && is_array($value)) {
             foreach ($value as $k2 => $v2) {
                 $preparedQuery[$key][$k2] = $this->prepareQueryOrNewObj($v2);
             }
             continue;
         }
         if (isset($key[0]) && $key[0] === '$' && is_array($value)) {
             $preparedQuery[$key] = $this->prepareQueryOrNewObj($value);
             continue;
         }
         list($key, $value) = $this->prepareQueryElement($key, $value, null, true);
         $preparedQuery[$key] = is_array($value) ? array_map('CosmoW\\ODM\\Riak\\Types\\Type::convertPHPToDatabaseValue', $value) : Type::convertPHPToDatabaseValue($value);
     }
     return $preparedQuery;
 }