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