Post::get PHP Method

get() public method

public get ( $id, array $with = [] ) : mixed
$id
$with array
return mixed
    public function get($id, array $with = [])
    {
        if (is_int($id)) {
            return Post::model()->public()->published()->with($with)->findByPk($id);
        }
        return Post::model()->public()->published()->with($with)->find('t.slug = :slug', [':slug' => $id]);
    }

Usage Example

 public function index()
 {
     Cache::loadPage('', 30);
     $inputData = array();
     $postid = 0;
     $curPage = 0;
     // Model::loadWithPath('home',System::getThemePath().'model/');
     if ($match = Uri::match('page\\/(\\d+)')) {
         $curPage = (int) $match[1];
     }
     $txtKeywords = addslashes(Request::get('txtKeywords', ''));
     if ($match = Uri::match('\\/keyword\\/(.*?)\\/page')) {
         $txtKeywords = base64_decode($match[1]);
     }
     $loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where title LIKE '%{$txtKeywords}%'", 'orderby' => "order by postid desc"));
     if (!isset($loadData[0]['postid'])) {
         Redirect::to('404page');
     }
     $inputData['newPost'] = $loadData;
     $inputData['keywords'] = $txtKeywords;
     $inputData['listPage'] = Misc::genPage('search/keyword/' . base64_encode($txtKeywords), $curPage);
     System::setTitle('Search result with keyword "' . $txtKeywords . '" results:');
     self::makeContent('search', $inputData);
     Cache::savePage();
 }
All Usage Examples Of Post::get