Created
December 30, 2014 09:41
-
-
Save lorenzo/e07ff5ef4a916f19ed2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Override default updateAll to workaround forced joins | |
* | |
* @return void | |
*/ | |
public function updateAll($fields, $conditions = true) { | |
$name = $this->name; | |
$this->name = '_model_'; | |
try { | |
$result = parent::updateAll($fields, $conditions); | |
} catch (Exception $e) { | |
$this->name = $name; | |
throw $e; | |
} | |
$this->name = $name; | |
return $result; | |
} | |
/** | |
* Override default deleteAll to workaround forced joins | |
* | |
* @return void | |
*/ | |
public function deleteAll($conditions, $dependent = true, $callbacks = false) { | |
$associated = []; | |
foreach ($this->getAssociated() as $model => $type) { | |
$associated[$type][] = $model; | |
} | |
$this->unbindModel($associated); | |
return parent::deleteAll($conditions, $dependent, $callbacks); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment