mardi 1 mars 2016

Unix time Format not working in Laravel where clause

I have a query in Laravel query builder like this. And I want to get data from a particular year

$query = blogs::where(array('blogs.status' => '1','blog_categories.status' => '1','categories.status' => '1','blogs.published' => '1'));

if (isset($year) and $year != NULL)$query->where("FROM_UNIXTIME(blogs.pubdate, '%Y')", '=', $year); 
    $result= $query->leftJoin('blog_categories', 'blog_categories.blogid', '=', 'blogs.blogid')->leftJoin('categories', 'blog_categories.catid', '=', 'categories.catid')->orderBy('blogs.publisheddate', 'desc')->count();

I got an error 'FROM_UNIXTIME' command. Here my 'blogs.pubdate' is in timestamp format (1456313400).Any idea?

Thanks for helping.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire