문제

I'm working on a php service. I'd like to pass an object with the parameters to use in the "where" clause and also the "order" and "limit" params.

I'm wondering whether there is a standard way/library to make up the query based on the parameters given, or whether I'll need to roll one.

I'm using ezsql to connect to mysql.

Any pointers, much appreciated.

도움이 되었습니까?

해결책

Writing one yourself shouldn't be too hard. If you don't want to do so (DRY, right?), you may check out sites like phpclasses.org or use an abstraction layer from Doctrine (take a look at its QueryBuilder if it is what you need)

다른 팁

Another suggestion if you would like to use already existing code: Zend Framework has a "query builder", Zend_Db_Select.

This does not require the whole Zend Framework, but it does have some depedencies you will have to include.

Documentation: http://framework.zend.com/manual/en/zend.db.select.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top