简体   繁体   中英

Empty parameters in codeigniter url

I have a controller which takes 4 parameters. Sometimes parameters can be empty. Standard url is like review/fetch_reviews/10/uk/topcomments/1234 where 10 represents count for paging.If that parameter is blank then url becomes review/fetch_reviews//uk// and my sql query becomes select * from table limit uk,10 . I even set default value for parameters as bellow

function fetch_reviews($page="10",$banktype="",$country="",$filter=""){

how to handle this? Itried URI routing but t doesnt work.

You can set your functional parameter as optional and pass this optional value like

Url:

site.com/class/myfunction/para1/null/para3

and function

public function myfunction($para1,$para2="null",para3) { //function body }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM