Skip to content

Instantly share code, notes, and snippets.

@isopen
Last active February 14, 2020 10:11
Show Gist options
  • Save isopen/389be98683bb3efcdc39bff4c9b533d3 to your computer and use it in GitHub Desktop.
Save isopen/389be98683bb3efcdc39bff4c9b533d3 to your computer and use it in GitHub Desktop.
<?php
...
/**
* https://github.com/yiisoft/yii/issues/1197
*
* @param bool $resetDefault
*
* @return $this|GxActiveRecord
*/
public function resetScope($resetDefault = true)
{
$c = $this->getDbCriteria();
if ($resetDefault) {
$CDbCriteria = new CDbCriteria();
if (!empty($c)) {
foreach ($c as $key => $value) {
$c->$key = $CDbCriteria->$key;
}
}
} else {
$c = null;
}
$this->setDbCriteria($c);
return $this;
}
..
<?php
...
relations:resetScope
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment