Skip to content
Permalink
Browse files

Clean up ORM Query API.

  • Loading branch information...
dereuromark committed Jan 5, 2017
1 parent 945ff04 commit 758feacaa0c912920d6bc4a3d3f24807db5dcfba
Showing with 60 additions and 10 deletions.
  1. +60 −10 src/ORM/Query.php
@@ -880,22 +880,43 @@ public function counter($counter)
/**
* Toggle hydrating entities.
*
* If set to false array results will be returned
* If set to false array results will be returned.
*
* @param bool $enable Use a boolean to set the hydration mode.
* @return self
*/
public function enableHydration($enable)
{
$this->_dirty();
$this->_hydrate = (bool)$enable;
return $this;
}
/**
* @return bool
*/
public function isHydrationEnabled() {
return $this->_hydrate;
}
/**
* Toggle hydrating entities.
*
* If set to false array results will be returned.
*
* @deprecated 3.4.0 Use enableHydration()/isHydrationEnabled() instead.
* @param bool|null $enable Use a boolean to set the hydration mode.
* Null will fetch the current hydration mode.
* @return bool|self A boolean when reading, and $this when setting the mode.
*/
public function hydrate($enable = null)
{
if ($enable === null) {
return $this->_hydrate;
return $this->isHydrationEnabled();
}
$this->_dirty();
$this->_hydrate = (bool)$enable;
return $this;
return $this->enableHydration($enable);
}
/**
@@ -1180,23 +1201,52 @@ public function jsonSerialize()
return $this->all();
}
/**
* Sets whether or not the ORM should automatically append fields.
*
* By default calling select() will disable auto-fields. You can re-enable
* auto-fields with this method.
*
* @param bool $value Set true to enable, false to disable.
* @return self
*/
public function enableAutoFields($value)
{
$this->_autoFields = (bool)$value;
return $this;
}
/**
* Gets whether or not the ORM should automatically append fields.
*
* By default calling select() will disable auto-fields. You can re-enable
* auto-fields with enableAutoFields().
*
* @return bool The current value.
*/
public function isAutoFieldsEnabled()
{
return $this->_autoFields;
}
/**
* Get/Set whether or not the ORM should automatically append fields.
*
* By default calling select() will disable auto-fields. You can re-enable
* auto-fields with this method.
*
* @deprecated 3.4.0 Use enableAutoFields()/isAutoFieldsEnabled() instead.
* @param bool|null $value The value to set or null to read the current value.
* @return bool|self Either the current value or the query object.
*/
public function autoFields($value = null)
{
if ($value === null) {
return $this->_autoFields;
return $this->isAutoFieldsEnabled();
}
$this->_autoFields = (bool)$value;
return $this;
return $this->enableAutoFields($value);
}
/**
@@ -1209,7 +1259,7 @@ protected function _decorateResults($result)
{
$result = $this->_applyDecorators($result);
if (!($result instanceof ResultSet) && $this->bufferResults()) {
if (!($result instanceof ResultSet) && $this->isBufferedResultsEnabled()) {
$class = $this->_decoratorClass();
$result = new $class($result->buffered());
}

0 comments on commit 758feac

Please sign in to comment.
You can’t perform that action at this time.