/** * 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}); }
/** * 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; }