本文整理匯總了PHP中LSActiveRecord::beforeSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP LSActiveRecord::beforeSave方法的具體用法?PHP LSActiveRecord::beforeSave怎麽用?PHP LSActiveRecord::beforeSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LSActiveRecord
的用法示例。
在下文中一共展示了LSActiveRecord::beforeSave方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeSave
/**
* This method is invoked before saving a record (after validation, if any).
* The default implementation raises the {@link onBeforeSave} event.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
* Make sure you call the parent implementation so that the event is raised properly.
* @return boolean whether the saving should be executed. Defaults to true.
*/
public function beforeSave()
{
if ($this->usesleft > 0) {
$this->completed = 'N';
}
return parent::beforeSave();
}
示例2: beforeSave
/**
* This method is invoked before saving a record (after validation, if any).
* The default implementation raises the {@link onBeforeSave} event.
* You may override this method to do any preparation work for record saving.
* Use {@link isNewRecord} to determine whether the saving is
* for inserting or updating record.
* Make sure you call the parent implementation so that the event is raised properly.
* @return boolean whether the saving should be executed. Defaults to true.
*/
public function beforeSave()
{
// Postgres delivers bytea fields as streams :-o - if this is not done it looks like Postgres saves something unexpected
if (gettype($this->password) == 'resource') {
$this->password = stream_get_contents($this->password, -1, 0);
}
return parent::beforeSave();
}
示例3: beforeSave
/**
* Make sure we don't save a new question group
* while the survey is active.
*
* @return bool
*/
protected function beforeSave()
{
if (parent::beforeSave()) {
$surveyIsActive = Survey::model()->findByPk($this->sid)->active !== 'N';
if ($surveyIsActive && $this->getIsNewRecord()) {
return false;
}
return true;
} else {
return false;
}
}