Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm
Temporarily disable observers
Jume
April 2013
Is there a way to temporarily disable all ORM observers, without for example commenting them all?
Harro
April 2013
Accepted Answer
Something like this would be the cleanest solution:
class Model_Mine
{
protected $_observers_enabled = true;
public static observer_state($state = true)
{
static::$_observers_enabled = (boot) $state;
}
public function observe($event)
{
static::$_observers_enabled and parent::observe($event);
}
}
dkimery
September 2018
I know this old, but this helped me a lot. We needed to create an import function and in this situation I needed to set the created_at, update_by, etc with past dates. Thanks guys
:)
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
dkimery
September 2018
Harro
April 2013