php - paginate() function throwing exception - PDOException SQLSTATE[HY093]: Invalid parameter number for in Laravel -
i using below code fetch records database in laravel
$products = new product(); $products = $products->orderby('id', 'desc')->paginate(10);
but it's throwing exception
pdoexception sqlstate[hy093]: invalid parameter number
it's showing below error:
illuminate\database\queryexception sqlstate[hy093]: invalid parameter number (sql: select count(*) aggregate 'tbl_products' 'tbl_products'.'deleted_at' null , 'category_id' = 10 ,
created_at
between , ?)
i tried find solution posted here didn't work me.
before executing above code i've written code in function , think code affecting.
$timeframe = input::get('daterange'); $products = $products->wherebetween('created_at', $timeframe);
$products = new product(); $products = $products->orderby('id', 'desc')->paginate(10);
this not fetch records - creating new, empty product object, , trying query it.
to retrieve products , order , paginate them, try this:
$products = product::orderby('id', 'desc')->paginate(10);
Comments
Post a Comment