Can I find such a intelligent function to deal with all query conditions in database -
if want query in database, can use conditions, such select * user id=1; can define function :
bool query(int id,string tablename) { database.id.equalto(id); }
if want find user less 18(age) years old:
bool query(int age,string tablename) { database.age.lessthan(age); }
so 2 conditions have 2 function relative.
can find such way ,that
bool query(string condition) { database.find(condition); //it deal condition intelligent use required function. }
i know database can read sql syntax. want find function can provide developer convenient way without writing sql syntax, pass condition sentence that: age<18, id=1. , function return result1.when enter arg>19 function return result2. not sure if have mention problem clearly. seeking help!
for php can use doctrine orm. doctrine 2 object-relational mapper (orm) php 5.4+ provides transparent persistence php objects.
the 'where' clause should need.
http://doctrine-orm.readthedocs.org/en/latest/reference/query-builder.html#high-level-api-methods
similar querybuilders exist in other languages. no need reinvent wheel.
http://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started.html
Comments
Post a Comment