本文整理汇总了PHP中CActiveRecord::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::afterSave方法的具体用法?PHP CActiveRecord::afterSave怎么用?PHP CActiveRecord::afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
protected function afterSave()
{
if (parent::afterSave()) {
//die($this->id);
//return $this->id;
}
}
示例2: afterSave
public function afterSave()
{
if (!$this->isNewRecord) {
Syslog::add(Logs::LOG_EDITED, 'Изменен комментарий к бану № <strong>' . $this->bid . '</strong>, написанный пользователем <strong>' . $this->name . '</strong>');
}
return parent::afterSave();
}
示例3: afterSave
protected function afterSave()
{
parent::afterSave();
$this->validateServerFile('serverFile', null);
require_once 'Image.php';
// 保存图片
if ($this->hasErrors('serverFile') == false && $this->serverFile instanceof CUploadedFile) {
// 保存原图
$file = $this->serverFile;
$fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
$filePath = Helper::mediaPath(Server::UPLOAD_ORIGINAL_FILE_PATH . $fileName, FRONTEND);
$file->saveAs($filePath);
// 如果是图片需要进行裁切
if (strtolower($file->extensionName) != 'swf') {
// 裁切大图
// 位置不同图片尺寸不同
$image = new Image($filePath);
$image->resize(350, 230)->save(Helper::mediaPath(Server::UPLOAD_THUMBNAIL_IMAGE_PATH . $fileName, FRONTEND));
}
// 更新数据
$this->updateByPk($this->primaryKey, array('image_path' => $fileName));
} else {
if ($this->deleteServerFile) {
// 删除图片
@unlink(Helper::mediaPath(Server::UPLOAD_ORIGINAL_FILE_PATH . $this->image_path, FRONTEND));
@unlink(Helper::mediaPath(Server::UPLOAD_THUMBNAIL_IMAGE_PATH . $this->image_path, FRONTEND));
// 更新数据
$this->updateByPk($this->primaryKey, array('image_path' => ''));
}
}
}
示例4: afterSave
protected function afterSave()
{
parent::afterSave();
$images = CUploadedFile::getInstances($this, 'images');
if (isset($images) && count($images) > 0) {
foreach ($images as $k => $img) {
$imageName = md5(microtime()) . '.jpg';
if ($img->saveAs($this->getFolder() . $imageName)) {
$advImg = new Image();
$advImg->goods_id = $this->getPrimaryKey();
$advImg->image = $imageName;
$advImg->save();
}
}
}
if ($this->isNewRecord) {
$count = new Count();
$count->goods_id = $this->id;
$count->count = $this->count;
$count->size = $this->size;
$count->color = $this->color;
$count->save();
} else {
Count::model()->updateAll(array('goods_id' => $this->id, 'count' => $this->count, 'size' => $this->size, 'color' => $this->color), 'goods_id=:goods_id', array(':goods_id' => $this->id));
}
}
示例5: afterSave
/**
* Notify everyone that was @mentioned in this share by email that they were mentioned
*/
public function afterSave()
{
preg_match_all('/@([A-Za-z0-9\\/\\.]*)/', $this->text, $matches);
$mentions = implode(',', $matches[1]);
if (!empty($matches[1])) {
/* $criteria = new CDbCriteria;
$criteria->addInCondition('username', $matches[1]);
$users = User::model()->findAll($criteria);
foreach ($users as $user)
{
$sendgrid = new SendGrid(Yii::app()->params['includes']['sendgrid']['username'], Yii::app()->params['includes']['sendgrid']['password']);
$email = new SendGrid\Email();
$email->setFrom(Yii::app()->params['includes']['sendgrid']['from'])
->addTo($user->email)
->setSubject("You've Been @mentioned!")
->setText("You've Been @mentioned!")
->setHtml(Yii::app()->controller->renderPartial('//email/mention', array('share' => $this, 'user' => $user), true));
// Send the email
$sendgrid->send($email);
}*/
}
return parent::afterSave();
}
示例6: afterSave
protected function afterSave()
{
parent::afterSave();
$this->validateBannerFile('bannerFile', null);
require_once 'Image.php';
// 保存图片
if ($this->hasErrors('bannerFile') == false && $this->bannerFile instanceof CUploadedFile) {
// 保存原图
$file = $this->bannerFile;
$fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
$filePath = Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND);
$file->saveAs($filePath);
// 如果是图片需要进行裁切
// 右侧底图
if (strtolower($file->extensionName) != 'swf') {
$image = new Image($filePath);
$image->save(Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND));
}
// 更新数据
$this->updateByPk($this->primaryKey, array('banner_path' => $fileName));
} else {
if ($this->deleteBannerFile) {
@unlink(Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $this->banner_path, FRONTEND));
// 更新数据
$this->updateByPk($this->primaryKey, array('banner_path' => ''));
}
}
}
示例7: afterSave
public function afterSave()
{
if ($this->isNewRecord) {
$this->created_date = new CDbExpression('NOW()');
}
parent::afterSave();
}
示例8: afterSave
public function afterSave()
{
if ($this->_newRecord) {
Yii::app()->authManager->assign('Member', 'Member-' . $this->id);
}
return parent::afterSave();
}
示例9: afterSave
protected function afterSave()
{
parent::afterSave();
if (!$this->textarea) {
$this->info = $this->unparse($this->info);
}
}
示例10: AfterSave
public function AfterSave()
{
$this->refresh();
if ($this->activo == '1') {
$this->activacion($this->hcodimpuesto);
}
return parent::afterSave();
}
示例11: afterSave
public function afterSave()
{
$pk = (empty($this->primaryKey) or is_array($this->primaryKey)) ? 'id' : $this->primaryKey;
if (isset($this->{$pk}) and empty($this->{$pk})) {
$this->{$pk} = Yii::app()->db->lastInsertID;
}
return parent::afterSave();
}
示例12: afterSave
public function afterSave()
{
if ($this->isNewRecord) {
$this->created_date = new CDbExpression('NOW()');
$this->core_user_id = Yii::app()->user->id;
}
parent::afterSave();
}
示例13: afterSave
public function afterSave()
{
/* insert default nodes */
if ($this->isNewRecord) {
Node::model()->insertDefaultNodes($this->id);
}
return parent::afterSave();
}
示例14: afterSave
public function afterSave()
{
parent::afterSave();
if ($this->isNewRecord) {
$this->book->n_chapters++;
$this->book->save(false, array("n_chapters"));
}
}
示例15: afterSave
public function afterSave()
{
if ($this->dateDBformat) {
$this->dateDBformat = false;
$this->date = date(Yii::app()->locale->getDateFormat('phpshort'), strtotime($this->date));
}
return parent::afterSave();
}