本文整理汇总了PHP中CActiveRecord::beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::beforeSave方法的具体用法?PHP CActiveRecord::beforeSave怎么用?PHP CActiveRecord::beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->id_empresa = Yii::app()->user->model->id_empresa;
}
return parent::beforeSave();
}
示例2: beforeSave
public function beforeSave()
{
parent::beforeSave();
$picture = CUploadedFile::getInstance($this, 'image');
if ($picture) {
$imagename = $picture->getTempName();
$image = Yii::app()->image->load($imagename);
if ($image) {
if ($this->avatar) {
unlink($_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $this->avatar);
}
if ($image->width >= $image->height) {
$image->resize(20000, 93)->rotate(0)->quality(90)->sharpen(20);
} else {
$image->resize(93, 20000)->rotate(0)->quality(90)->sharpen(20);
}
$image->crop(93, 93);
$file_name = rand() . '.' . $picture->extensionName;
$savename = $_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $file_name;
$image->save($savename);
$this->avatar = $file_name;
}
}
return true;
}
示例3: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->datahora_insercao = new CDbExpression('NOW()');
}
return parent::beforeSave();
}
示例4: beforeSave
protected function beforeSave()
{
if (substr($this->url, 0, strlen('http')) !== 'http') {
$this->url = "http://" . $this->url;
}
return parent::beforeSave();
}
示例5: beforeSave
protected function beforeSave()
{
if (parent::beforeSave()) {
$this->userId = Yii::app()->user->userId;
}
return true;
}
示例6: beforeSave
protected function beforeSave()
{
if (parent::beforeSave()) {
if ($this->album_id == 0) {
$this->album_id = null;
}
if ($this->isNewRecord) {
$this->click = 0;
$this->add_uid = Yii::app()->user->id;
$this->add_time = time();
if ($this->url == "") {
if ($this->musicfile) {
$name = $this->musicfile->name;
$this->url = $name;
}
}
} else {
if ($this->musicfile) {
$name = $this->musicfile->name;
$this->url = $name;
}
}
return true;
} else {
return false;
}
}
示例7: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->position = count(Components::model()->findAll("projectId = {$this->projectId}")) + 1;
}
return parent::beforeSave();
}
示例8: beforeSave
protected function beforeSave()
{
if (parent::beforeSave()) {
$this->spotNum++;
}
return true;
}
示例9: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->created = date('Y/m/d H:i:s');
}
return parent::beforeSave();
}
示例10: beforeSave
protected function beforeSave()
{
if (!parent::beforeSave()) {
return false;
}
if (($this->scenario == 'insert' || $this->scenario == 'update') && ($this->icon = CUploadedFile::getInstance($this, 'icon'))) {
// Если обновляем запись, то удаляем прошлую фотографию
if ($this->scenario == 'update') {
$file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $this->img;
$fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $this->img;
if (file_exists($file) and $this->img != '') {
unlink($file);
}
if (file_exists($fileMini) and $this->img != '') {
unlink($fileMini);
}
}
$fileName = mktime(date("i")) . '.jpg';
$this->img = $fileName;
$file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $fileName;
$this->icon->saveAs($file);
//Делаем ресайз только что загруженному изображению
$Image = Image::factory("./Image/Project/" . $fileName);
if ($Image->width >= $Image->height) {
$Image->resize(375, 410, Image::WIDTH)->crop(375, 410, "top", "center");
$Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
} else {
$Image->resize(235, 314, Image::HEIGHT)->crop(235, 314, "top", "center");
$Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
}
}
return true;
}
示例11: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->created = time();
}
return parent::beforeSave();
}
示例12: beforeSave
public function beforeSave()
{
if (isset($_POST['items'])) {
$this->modulos = join(',', $_POST['items']);
}
return parent::beforeSave();
}
示例13: beforeSave
public function beforeSave()
{
//if (strpos($this->nombre,'@')!==false){
$this->nombre = '@' . strtolower(trim($this->nombre, '@'));
//}
return parent::beforeSave();
}
示例14: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->status = self::STATUS_OK;
}
return parent::beforeSave();
}
示例15: beforeSave
public function beforeSave()
{
if ($this->isNewRecord)
$this->creation_date = new CDbExpression('NOW()');
return parent::beforeSave();
}