本文整理汇总了PHP中ActiveRecord::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::beforeSave方法的具体用法?PHP ActiveRecord::beforeSave怎么用?PHP ActiveRecord::beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave()
{
if ($this->id === self::LEVEL_ENGINEER) {
$this->banned_resources_inheritance = NULL;
}
return parent::beforeSave();
}
示例2: beforeSave
/**
* Before save operations
*/
public function beforeSave()
{
if ($this->isNewRecord) {
$this->user_id = Yii::app()->user->id;
}
return parent::beforeSave();
}
示例3: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->user_id = user()->getId();
}
return parent::beforeSave();
}
示例4: beforeSave
public function beforeSave()
{
if (!empty($this->id)) {
$this->setProfileImage();
}
return parent::beforeSave();
}
示例5: beforeSave
function beforeSave()
{
parent::beforeSave();
if ($this->validate()) {
$this->password = $this->hashPassword($this->password);
}
return true;
}
示例6: beforeSave
protected function beforeSave()
{
if ($this->getIsNewRecord()) {
$this->ip = userIp();
$this->user_agent = request()->getUserAgent();
}
return parent::beforeSave();
}
示例7: beforeSave
public function beforeSave()
{
$scoord = explode(',', $this->start_coords);
$this->start_coords = new CDbExpression("GeomFromText(:start_point)", array(':start_point' => 'POINT(' . $scoord[0] . ' ' . $scoord[1] . ')'));
$ecoord = explode(',', $this->end_coords);
$this->end_coords = new CDbExpression("GeomFromText(:end_point)", array(':end_point' => 'POINT(' . $ecoord[0] . ' ' . $ecoord[1] . ')'));
return parent::beforeSave();
}
示例8: beforeSave
/**
* Asignando anho y id del ente organo al cual pertenece el usuario.
*/
public function beforeSave()
{
if ($this->isNewRecord) {
$this->anho = 2015;
$this->ente_organo_id = Usuarios::model()->findByPk(Yii::app()->user->getId())->enteOrgano->ente_organo_id;
}
return parent::beforeSave();
}
示例9: beforeSave
protected function beforeSave()
{
if ($this->isNewRecord) {
$this->referer = self::generateRefererCode();
$this->registration_ip = userIp();
}
return parent::beforeSave();
}
示例10: beforeSave
/**
* Asignando anho y id del ente organo al cual pertenece el usuario.
*/
public function beforeSave()
{
if ($this->isNewRecord) {
$this->anho = Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho'];
$this->ente_organo_id = Usuarios::model()->findByPk(Yii::app()->user->getId())->enteOrgano->ente_organo_id;
}
return parent::beforeSave();
}
示例11: beforeSave
/**
* Обработка данных перед сохранением
*/
protected function beforeSave()
{
if ($this->isNewRecord) {
if (is_numeric(user()->getId())) {
$this->user_id = user()->getId();
}
}
return parent::beforeSave();
}
示例12: beforeSave
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
$this->created_at = time();
return true;
} else {
return false;
}
}
示例13: beforeSave
public function beforeSave()
{
if ($this->getIsNewRecord()) {
if (empty($this->from_user_id)) {
$this->from_user_id = Yii::app()->user->id;
}
}
return parent::beforeSave();
}
示例14: beforeSave
/**
* Before save operations
*/
public function beforeSave()
{
// Check to make sure the theme dir is writeable
$path = Yii::getPathOfAlias('application.www.themes');
if (!is_writeable($path)) {
$this->addError('dirname', at('Sorry, We could not create the theme directory as the theme path "{d}" is not writeable. Please set the appropriate permissions.', array('{d}' => $path)));
return;
}
return parent::beforeSave();
}
示例15: beforeSave
protected function beforeSave()
{
if ($this->protected_ip) {
$ipList = str_replace(array("\r"), '', $this->protected_ip);
$ipList = explode("\n", $ipList);
$ipList = array_map('trim', $ipList);
$this->protected_ip = json_encode($ipList);
}
return parent::beforeSave();
}