Beispiel #1
0
 /**
  * Gets the serialized value of the given field.
  * @param Field $field The field.
  * @return string Serialized value of the field.
  */
 public function getField(Field $field)
 {
     if (!$this->isConstructed()) {
         throw new \BadMethodCallException("Not yet constructed");
     }
     $fieldName = $field->getName();
     return $field->serializeValue($this->{$fieldName});
 }
Beispiel #2
0
 /**
  * Orders the results in descending order based on the value of this field.
  * @param Field $field The field to sort on.
  * @throws BadMethodCallException If {@link Field#needsJoin()} returns true.
  * @return Query This object.
  */
 public function orderDescending(Field $field)
 {
     if ($field->needsJoin()) {
         throw new BadMethodCallException("Field " . $field->getName() . " needs a join, so cannot be used for sorting");
     }
     $this->orderByStrings[] = '`' . $field->getNameInDatabase() . "` DESC";
     return $this;
 }