php - Does save() method works of update in Yii -
i have message model class. want check weather particular entry exist in db table. if doesn't exist save new entry in db table , if exists update current entry.
now problem when entry exists (update) in db table, save() method gives exception. 'chttpexception' message 'your request invalid.'
can use save() method instead of update() method updating records?
$message = message::model()->find($criteriamessage); if (!isset($message)){ $message = new message(); $message->id = $tagmessage->id; $message->language = $language; $message->translation = $translation; } else $message->translation = $translation; if(!$message->save()){ return false; }
you do:
$message = message::model()->find($criteriamessage); $message->your_field = $somevalue; $message->save();
Comments
Post a Comment