Exemple #1
0
 /**
  * Gets the query expression that the comparison expression
  * is enforcing. Currently this supports equality only, so an
  * expression like id < 3 will yield ':', which matches all ids.
  * An expression like id == 3 will yield the query for the field
  * 'id' for the value 3.
  *
  * Only comparisons between a field and a constant are valid.
  *
  * @return associative array where the keys are the query expressions
  *         and they all map to 1.
  */
 public function get_queries()
 {
     if ($this->op != '==') {
         // can only index by equality
         return parent::get_queries();
     }
     if ($this->right instanceof FQLConstantExpression && $this->left instanceof FQLFieldExpression) {
         // expression is something like "id == 3"
         $query = $this->left->field->get_query($this->right->evaluate(null));
     } else {
         if ($this->left instanceof FQLConstantExpression && $this->right instanceof FQLFieldExpression) {
             // expression is something like "3 == id"
             $query = $this->right->field->get_query($this->left->evaluate(null));
         } else {
             return parent::get_queries();
         }
     }
     if (isset($query) && $query) {
         return array($query => 1);
     } else {
         // this means that we're sure there are no matches.  e.g. you did a
         // search for groups where id == -5 or something.
         return array();
     }
 }