Fatal Error Memory After Construct Of Cactiverecord

Hi!

I have a class licence which extends CActivre Record. I want to create a construct in this class. Here is my code:


class licence extends CActiveRecord

{

	static $LICENCE_STORAGE_DIRECTORY;

	public function __construct()

	{

		parent::__construct();

		if(YII_DEBUG)

			self::$LICENCE_STORAGE_DIRECTORY="my/debug/directory";

		else

			self::$LICENCE_STORAGE_DIRECTORY="my/prod/directory";		

	}

...

}

Each time my code create an object licence, I’ve got this error:

If I comment call of parent constructor, my object is not instanciate but it works…

Any ideas?

Raise PHP’s memory_limit as an intermediate fix.

I’ve tied to set my limit to 2Go, always the same problem. It must be an infinite loop somewhere but I don’t know why…

Hm, well. Can you try to store your logic insinde an init() method instead of overwriting CActiveRecord’s constructor?

Thanks!

It works like this:


public function init()

{

	if(YII_DEBUG)

		self::$LICENCE_STORAGE_DIRECTORY="my/debug/path";

	else

		self::$LICENCE_STORAGE_DIRECTORY="my/prod/path";	

}

It’s strange… a constructor lik this should be the same than no constructor:


public function __construct()

{

	parent::__construct();	

}

But it doesnt work like this…

Hi make sure in your main index file YII_DEBUG is true

like


defined('YII_DEBUG') or define('YII_DEBUG',true);

The manual advises against overloading the constructor. You can instead overload the init() method.