سؤال

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