Database 我能找到这样一个智能函数来处理数据库中的所有查询条件吗
若要查询数据库中的某些内容,可以使用where条件,例如select*from user where id=1; 我可以定义一个函数:Database 我能找到这样一个智能函数来处理数据库中的所有查询条件吗,database,Database,若要查询数据库中的某些内容,可以使用where条件,例如select*from user where id=1; 我可以定义一个函数: bool查询(int-id,string-tableName) { 数据库.id.equalTo(id); } 如果我想找到18岁以下的用户: bool query(int age,string tableName) { database.age.lessthan(age); } 对于两个条件,我们有两个相对函数 我能找到这样一种方法吗 bool que
bool查询(int-id,string-tableName)
{
数据库.id.equalTo(id);
}
如果我想找到18岁以下的用户:
bool query(int age,string tableName)
{
database.age.lessthan(age);
}
对于两个条件,我们有两个相对函数
我能找到这样一种方法吗
bool query(string condition)
{
database.find(condition);
//it will deal with the condition intelligent use the required function.
}
我知道数据库可以读取sql语法。但是我想找到一个函数,它可以为开发人员提供一种方便的方式,而无需编写sql语法,只需传递条件语句:age 19函数返回result2。
我不确定我是否清楚地提到了我的问题。寻求帮助 对于PHP,您可以使用ORM。条令2是PHP5.4+的对象关系映射器(ORM),为PHP对象提供透明持久性 “where”子句应该满足您的需要 其他语言中也存在类似的QueryBuilder。不需要重新发明轮子
这就是LINQ在.Net中要实现的目标。