i using cakephp. , have written cakephp find queries inside routes file. requirement create dynamic url. have doubts whether safe write queries in route file or there chances of sql injection this. if unsafe threats affect website , should prevent these web threats.
no sounds terrible code smell.
what want sounds want use slugs or resolve urls in db. here how right:
- create custom route class (slugroute, dblookuproute...)
- create model method (myurlmodel::lookup($url) example) actual lookup
- load model in route class
- use custom route class in routes.php
- optional good idea implement: caching of route lookup.
all of above described on book.cakephp.org, pay attention chapter router.
Comments
Post a Comment