Post::search PHP Method

    public function search()
    {
        $criteria = new CDbCriteria();
        $criteria->compare('t.id', $this->id, true);
        $criteria->compare('blog_id', $this->blog_id);
        $criteria->compare('t.create_user_id', $this->create_user_id, true);
        $criteria->compare('t.update_user_id', $this->update_user_id, true);
        $criteria->compare('t.create_time', $this->create_time);
        $criteria->compare('t.update_time', $this->update_time);
        $criteria->compare('t.slug', $this->slug, true);
        if ($this->publish_time) {
            $criteria->compare('DATE(from_unixtime(publish_time))', date('Y-m-d', strtotime($this->publish_time)));
        }
        $criteria->compare('title', $this->title, true);
        $criteria->compare('quote', $this->quote, true);
        $criteria->compare('content', $this->content, true);
        $criteria->compare('link', $this->link, true);
        $criteria->compare('t.status', $this->status);
        $criteria->compare('comment_status', $this->comment_status);
        $criteria->compare('access_type', $this->access_type);
        $criteria->compare('t.category_id', $this->category_id, true);
        $criteria->with = ['createUser', 'updateUser', 'blog'];
        return new CActiveDataProvider('Post', ['criteria' => $criteria, 'sort' => ['defaultOrder' => 't.publish_time DESC, t.id DESC']]);
    }

Usage Example

示例#1
0
 public function results()
 {
     $keywords = Input::get('words');
     $this->data['words'] = strip_tags($keywords);
     $this->data['results'] = Post::search($keywords);
     if (count($this->data['results']) === 1) {
         return Illuminate\Support\Facades\Redirect::to(WebAPL\Language::url('topost/' . $this->data['results'][0]->id));
     }
     WebAPL\Template::setPageTitle("Search: {$this->data['words']}", true);
     PageController::loadGeneralResources();
     $this->layout->content = View::make('sections.search.results', $this->data);
 }
All Usage Examples Of Post::search