本文整理汇总了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;
}
}