質問

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