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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -