예제 #1
0
 public function index($request)
 {
     $this->renderType = 'smarty';
     $name = $request->post('name');
     $list = Post::findAll();
     $list = Post::select()->where()->all();
     $row = Post::select()->where(['id' => 1])->one();
     return $list;
 }
예제 #2
0
 private static function getPostDataIds(array &$carry)
 {
     /**
      * Find postDataIds owned by threads and posts (which owned by threads)
      */
     foreach (Thread::findAll($carry['threadsIds']) as $thread) {
         $carry['postDataIds'][] = $thread->postDataId;
         foreach ($thread->posts as $post) {
             $carry['postDataIds'][] = $post->postData->id;
         }
     }
     /**
      * Find postDataIds owned by posts
      */
     foreach (Post::findAll($carry['postsIds']) as $post) {
         $carry['postDataIds'][] = $post->postDataId;
     }
 }
 public function actionGetfollowerpost()
 {
     $check_post = 0;
     $id = $_POST['id'];
     $follow = new Follow();
     $follow->studentID = $id;
     $model = array();
     $model = Follow::findAll(['studentID' => $id]);
     $status = array();
     $statuss = array();
     if ($model == Null) {
         $status["status"] = "faild";
         $statuss["status"] = "null";
     } else {
         $status["status"] = "ok";
         $statuss["status"] = "ok";
         for ($j = 0; $j < sizeof($model); $j++) {
             $status["follower"][$j] = $model[$j]->staffID;
         }
         $i = 0;
         $m = 0;
         $k = 0;
         for ($i = 0; $i < sizeof($model); $i++) {
             $staff_id = $model[$i]->staffID;
             $posts = array();
             $posts = Post::findAll(['owner' => $staff_id]);
             if ($posts == Null) {
                 //$statuss["status"]="faild";
                 $check_post++;
             } else {
                 $status["status"] = "ok";
                 $statuss["status"] = "ok";
                 for ($m = 0; $m < sizeof($posts); $m++) {
                     $name = "";
                     $statuss["content"][$k] = $posts[$m]->content;
                     //=$posts[$m] ->content;
                     $statuss["owner"][$k] = $posts[$m]->owner;
                     $name = StaffController::GetStaffName($statuss["owner"][$k]);
                     $statuss["name"][$k] = $name;
                     $statuss["time"][$k] = $posts[$m]->time;
                     $k++;
                 }
                 //$k += sizeof($posts);
             }
         }
     }
     if ($check_post == sizeof($model)) {
         $statuss["post"] = "null";
     } else {
         $statuss["post"] = "full";
     }
     return json_encode($statuss);
 }