public static function mapWithUsername(UserComment $comment, array $properties) { if (array_key_exists('username', $properties)) { $comment->setUsername($properties['username']); } if (array_key_exists('comment_id', $properties)) { $comment->setComment_id((int) $properties['comment_id']); } if (array_key_exists('comment', $properties)) { $comment->setComment($properties['comment']); } if (array_key_exists('user_id', $properties)) { $comment->setUser_id((int) $properties['user_id']); } if (array_key_exists('item_id', $properties)) { $comment->setItem_id((int) $properties['item_id']); } }
public function actionRead($id) { $model = $this->loadModel($id); $userMessage = UserMessage::model()->find("user_id = " . Yii::app()->user->id . " AND message_id = {$id}"); if (isset($userMessage)) { $userMessage->message_read = 1; $userMessage->save(); } $comments = $model->userComments; $newComment = new UserComment(); if (isset($_POST['UserComment'])) { $newComment->attributes = $_POST['UserComment']; $newComment->user_id = Yii::app()->user->id; $newComment->created = date('Y-m-d H:i:s'); $newComment->message_id = $id; $newComment->modified = date('Y-m-d H:i:s'); if ($newComment->validate()) { $newComment->save(); $comments = $model->userComments; $newComment = new UserComment(); } else { // die(print_r($newComment->getErrors())); } } $this->render('readMessage', array('model' => $model, 'comments' => $comments, 'newComment' => $newComment)); }
public function testQueryLimit() { $comments = UserComment::where(q::user_id(1))->limit(2); $this->assertEquals(2, count($comments)); $comments = UserComment::where(q::user_id(1))->limit(1); $this->assertEquals(1, count($comments)); }