yii-events

Foreign Key not storing in Yii

情到浓时终转凉″ 提交于 2019-12-01 10:45:01
问题 I have adatabase like this ====Group===== id name ====Member==== id group_id firstname lastname membersince Now as group_id is foreign key then when I will save Group tabale then the group_id should be save with that number. In relations I have made relations for Group is public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'member' => array(self::HAS_MANY, 'Member',

How to use events in Yii

依然范特西╮ 提交于 2019-11-30 14:06:22
问题 I want to run some code in the onBeginRequest event. Where do I do that? I assume I am not suppose to add this in the core library code. I am a totally noob in Yii 回答1: If you want to use onBeginRequest and onEndRequest you can do it by adding the next lines into your config file: return array ( ... 'onBeginRequest'=>array('Y', 'getStats'), 'onEndRequest'=>array('Y', 'writeStats'), ... ) or you can do it inline Yii::app()->onBeginRequest= array('Y', 'getStats'); Yii::app()->onEndRequest=