當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Table::beforeInsert方法代碼示例

本文整理匯總了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);
 }
開發者ID:vikash124,項目名稱:atk4-web,代碼行數:19,代碼來源:SurveyResult.php

示例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);
 }
開發者ID:vikash124,項目名稱:atk4-web,代碼行數:13,代碼來源:User.php

示例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));
 }
開發者ID:romaninsh,項目名稱:jobeet,代碼行數:5,代碼來源:Job.php


注:本文中的Model_Table::beforeInsert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。