本文整理匯總了PHP中Model_Table::beforeInsert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Table::beforeInsert方法的具體用法?PHP Model_Table::beforeInsert怎麽用?PHP Model_Table::beforeInsert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Table
的用法示例。
在下文中一共展示了Model_Table::beforeInsert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeInsert
function beforeInsert(&$data)
{
$c = get_class($this);
$c = preg_replace('/^Model_/', '', $c);
$survey = $this->add('Model_ATK_Survey');
$survey->loadBy('model', $c);
if (!$survey->isInstanceLoaded()) {
throw $this->exception('Survey not found')->addMoreInfo('class', $c);
}
$us = $this->add('Model_ATK_UserSurvey');
$us->setMasterField('user_id', $this->api->auth->get('id'));
$us->loadBy('survey_id', $survey->get('id'));
if (!$us->isInstanceLoaded()) {
$us->update(array('survey_id' => $survey->get('id')));
}
$data['user_survey_id'] = $us->get('id');
$data['is_completed'] = false;
return parent::beforeInsert($data);
}
示例2: beforeInsert
function beforeInsert($data)
{
// even when children add more conditions, email shouldn't duplicate!
$em = $data['email'];
if (!$em) {
$em = $this->get('email');
}
$m = $this->add('Model_ATK_User')->getBy('email', $em);
if ($m) {
throw $this->exception('This email is already registered', 'ValidityCheck')->setField('email');
}
return parent::beforeInsert($data);
}
示例3: beforeInsert
function beforeInsert(&$data){
parent::beforeInsert($data);
$data['expires_at']=date('Y-m-d',strtotime('+'.$this->api->getConfig('job/expires','30 days')));
$data['token']=sha1($data['email'].rand(11111, 99999));
}