当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::model方法代码示例

本文整理汇总了PHP中Posts::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::model方法的具体用法?PHP Posts::model怎么用?PHP Posts::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Posts的用法示例。


在下文中一共展示了Posts::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getWishListForWeb

 public function getWishListForWeb($user_id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "user_id = {$user_id}";
     $wishlists = Wishlist::model()->findAll($criteria);
     $wishlist_arr = array();
     foreach ($wishlists as $wishlist) {
         $wishlist_arr[] = $wishlist->post_id;
     }
     //var_dump($wishlist_arr); die;
     $returnArr = array();
     $criteria_post = new CDbCriteria();
     $criteria_post->addInCondition('t.post_id', $wishlist_arr);
     $count = Posts::model()->count($criteria_post);
     $pages = new CPagination($count);
     $pages->validateCurrentPage = FALSE;
     $pages->pageSize = Yii::app()->params['RESULT_PER_PAGE'];
     $pages->applyLimit($criteria_post);
     $posts = Posts::model()->findAll($criteria_post);
     $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
     $profile = User::model()->findByPk($user_id);
     foreach ($posts as $post) {
         $itemArr = Posts::model()->getPostById($post->post_id, Yii::app()->session['user_id']);
         $returnArr[] = $itemArr;
     }
     return array('data' => $returnArr, 'pages' => $pages, 'profile' => $profile, 'is_followed' => $is_followed);
     // return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:28,代码来源:Wishlist.php

示例2: actionShowPosts

 public function actionShowPosts($id, $mid, $sid)
 {
     $posts = Posts::model()->findByPk($sid);
     $multimedia = json_decode($posts->multimedia);
     $count = count($multimedia);
     foreach ($multimedia as $ind => $file) {
         if ($file->nomber == $mid) {
             $num = $ind + 1;
             if ($ind == 0) {
                 $prev = $multimedia[$count - 1]->nomber . '/' . $sid;
             } else {
                 $prev = $multimedia[$ind - 1]->nomber . '/' . $sid;
             }
             if ($ind == $count - 1) {
                 $next = $multimedia[0]->nomber . '/' . $sid;
             } else {
                 $next = $multimedia[$ind + 1]->nomber . '/' . $sid;
             }
             $current_photo = $file;
         }
     }
     $myPage = $id == Yii::app()->user->id;
     $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
     $ext = Files::model()->findByPk($current_photo->id)->extension;
     $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
     $comments = Comments::model()->getLast('posts_' . $sid, $mid, 10);
     $comments = array_reverse($comments);
     $file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date);
     $this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid));
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:30,代码来源:AphotosController.php

示例3: actionDelete

 public function actionDelete($mid)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $post = Posts::model()->findByPk($mid);
         if ($post->author_id == Yii::app()->user->id || $post->owner_id == Yii::app()->user->id) {
             // удаляем только если автор комментария == текущему авторизованному пользователю, либо если хозяин стены == текущему авторизованному пользователю
             // Удаление поста и его комментариев с использованием транзакций
             $transaction = $post->dbConnection->beginTransaction();
             PostsFiles::model()->deleteFiles($post->id);
             try {
                 $post->delete();
                 $transaction->commit();
                 $res = true;
             } catch (Exception $e) {
                 $transaction->rollback();
                 $res = false;
             }
             if ($res) {
                 echo json_encode(array('status' => 'ok'));
             } else {
                 echo json_encode(array('status' => 'error', 'data' => 'Не могу подключиться к БД'));
             }
         } else {
             throw new CException('Not Found', 404);
         }
     } else {
         throw new CException('Not Found', 404);
     }
 }
开发者ID:BGCX067,项目名称:facecom-svn-to-git,代码行数:29,代码来源:PostsController.php

示例4: actionInsertPostCeleb

 public function actionInsertPostCeleb()
 {
     $this->pageTitile = 'Thêm bài viết người nổi tiếng';
     $request = Yii::app()->request;
     try {
         $post_content = StringHelper::filterString($request->getPost('post_content'));
         $celeb_id = StringHelper::filterString($request->getPost('celeb_id'));
         $location = StringHelper::filterString($request->getPost('location'));
         $cats = $request->getPost('cats');
         if (count($_FILES['images']['tmp_name']) > 1) {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         } else {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         }
         // $album = StringHelper::filterString($request->getPost('album'));
         $album = NULL;
         $res = Posts::model()->addPostCeleb($celeb_id, $post_content, $location, $url_arr, $album, $cats);
         if ($res != FALSE) {
             Yii::app()->user->setFlash('success', 'Thêm bài viết thành công');
         } else {
             Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
         }
         $this->redirect(Yii::app()->createUrl('celebrity/addPost'));
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:27,代码来源:CelebrityController.php

示例5: blogSitemap

 /**
  * 文章
  */
 private function blogSitemap()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'classify=' . $this->classify . ' AND status=' . Posts::STATUS_PASSED;
     $criteria->select = 'id, cTime';
     $criteria->order = 'id ASC';
     $criteria->limit = $this->limitPerPage;
     $criteria->offset = $this->pageStart;
     $model = Posts::model()->findAll($criteria);
     foreach ($model as $k => $v) {
         $this->blogItems[] = array('url' => $this->webSiteTitle . '/post/' . $v->id . '.html', 'date' => date(DATE_W3C, $v->cTime));
         //$tagArr = preg_split('#,|,#i', $v->tag);
         if (!empty($tagArr)) {
             foreach ($tagArr as $k => $v) {
                 if (!in_array($v, $this->tagItems)) {
                     $this->tagItems[] = $v;
                 }
             }
         }
     }
     //创建临时函数数组
     $tmp = array();
     $tmp = $this->tagItems;
     $this->tagItems = array();
     foreach ($tmp as $k => $v) {
         $this->tagItems[] = array('url' => $this->webSiteTitle . '/posts/tag-' . $v->id . '.html', 'date' => date(DATE_W3C, time()));
     }
     unset($tmp);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:32,代码来源:Sitemap.php

示例6: actionView

 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     //		$this->render('view',array(
     //			'model'=>$this->loadModel($id),
     //		));
     $Posts = Posts::model()->findAll(array('condition' => "`secciones_idSeccion` = {$id}", 'limit' => 7, 'order' => 'fecha DESC'));
     $this->render('view', array('posts' => $Posts, 'model' => $this->loadModel($id)));
 }
开发者ID:nicoblakie,项目名称:arkasGroup,代码行数:12,代码来源:SeccionesController.php

示例7: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Posts the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Posts::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:ph7pal,项目名称:mei,代码行数:15,代码来源:PostsController.php

示例8: findAllCildrenAsArray

 public static function findAllCildrenAsArray($id)
 {
     $comment = Posts::model()->findByPk($id);
     $model = array_reduce($comment->children()->findAll(), function ($array, $item) {
         $array[] = $item->toJson();
         return $array;
     }, []);
     return $model;
 }
开发者ID:R0dgerV,项目名称:test-post-comment,代码行数:9,代码来源:Posts.php

示例9: actionStat

 public function actionStat()
 {
     $posts = Posts::model()->count();
     $commentsNum = Comments::model()->count();
     $attachsNum = Attachments::model()->count();
     $feedbackNum = Feedback::model()->count();
     $arr = array('posts' => $posts, 'commentsNum' => $commentsNum, 'attachsNum' => $attachsNum, 'feedbackNum' => $feedbackNum);
     $this->render('stat', $arr);
 }
开发者ID:ph7pal,项目名称:momo,代码行数:9,代码来源:IndexController.php

示例10: deletePost

 /**
  * This is method for delete post from list
  * @param  string $id postID
  * @return array[] {
  *         		'code':200,
  *         		'message':'SUCCESS'
  * }
  */
 public function deletePost($id)
 {
     $result = Posts::model()->findByAttributes(array('id' => $id));
     $result->status = '0';
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
开发者ID:itliuchang,项目名称:test,代码行数:17,代码来源:BCommunity.php

示例11: search

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('idSeccion', $this->idSeccion);
     $criteria->compare('nombre', $this->nombre, true);
     $post = Posts::model()->findByPk('1');
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
开发者ID:nicoblakie,项目名称:arkasGroup,代码行数:14,代码来源:Secciones.php

示例12: liked

 public function liked($id)
 {
     $result = Like::model()->findByAttributes(array('id' => $id));
     $result->status = 0;
     $post = Posts::model()->findByAttributes(array('id' => $result->postId));
     $post->like_num--;
     if ($result->save() && $post->save()) {
         echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => array('postId' => $result->postId)));
     }
 }
开发者ID:itliuchang,项目名称:test,代码行数:10,代码来源:CUser.php

示例13: actionDetailCategory

 public function actionDetailCategory()
 {
     $request = Yii::app()->request;
     try {
         $cat_id = StringHelper::filterString($request->getQuery('cat_id'));
         $data = Posts::model()->getPostByCategoryId($cat_id);
         $this->render('categoryById', $data);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:11,代码来源:CategoryController.php

示例14: actionExplore

 public function actionExplore()
 {
     try {
         //            $this->layoutPath = Yii::getPathOfAlias('webroot') . "/themes/frontend2/views/layouts";
         //            $this->layout = 'main_empty_2';
         $feed = Posts::model()->getExplore();
         $this->render('explore', $feed);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:11,代码来源:HomeController.php

示例15: actionSearchPostWeb

 public function actionSearchPostWeb()
 {
     $request = Yii::app()->request;
     try {
         $query = StringHelper::filterString($request->getQuery('query'));
         $data = Posts::model()->searchPost($query, Yii::app()->session['user_id']);
         //   var_dump($data); die;
         $this->render('index', $data);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:12,代码来源:SearchController.php


注:本文中的Posts::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。