企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
* [ ] 功能 * 组装查询条件 * 场景:user 数据库的 user_account 表只有 3 条数据,数据为: user_account 表 | uid | username | | :---: | :---: | | 1 | 张三 | | 2 | 李四 | | 3 | 隔壁老王 | * [ ] where方法的参数支持字符串和数组 * [ ] 字符串条件 * 查询用户名包含老王,并且用户ID大于1的所有用户记录 ~~~ $where = "username like `'%老王%' and uid > 1"; $data = mysql\User::table('account')->where( $where )->select(); ~~~ * [ ] 数组条件 * 查询用户名包含老王,并且用户ID大于1的所有用户记录 ~~~ $where = array( 'uid[>]' => 1, 'username[like]' => '老王', ); $data = mysql\User::table('account')->where( $where )->select(); ~~~ 查询结果: ~~~ array( array( 'uid' => 3, 'username' => '隔壁老王', ), ); ~~~ * [ ] 复杂组合条件 * 查询用户名包含老王且用户ID大于1,或者用户ID小于等于3的所有用户记录 ~~~ $where = array( 'or' => array( 'uid[<=]' => 3, 'and' => array( 'uid[>]' => 1, 'username[like]' => '老王', ), ), ); $data = mysql\User::table('account')->where($where)->select(); ~~~ * 查询用户名包含老王且用户ID大于1,或者用户ID小于等于3,或者用户ID大于1且用户名是李四的所有用户记录 ~~~ $where = array( 'or' => array( 'uid[<=]' => 3, 'and' => array( 'uid[>]' => 1, 'username[like]' => '老王', ), ), 'or1' => array( 'uid[>]' => 1, 'usernmae' => '李四', ), ); $data = mysql\User::table('account')->where($where)->select(); ~~~ * 查询表达式含义 | 表达式符号 | 表达式含义 | | :---: | :---: | | [not] in | 范围查询 | | [not] like | 模糊查询 | | [not] bet | 区间查询 | | [not] es | [NOT] EXISTS条件 | | .= | 字段匹配 | * [ ] 注意事项 * 不支持多次连贯调用where,如果多次连贯调用,以最后一次调用为准 * 多个 and,然后又是同一级,可以在以下字符串中选择 ~~~ and、and1、and2、and3、and4、and5、and6、and7、and8、and9、&& ~~~ * 多个 or,然后又是同一级,可以在以下字符串中选择 ~~~ or、or1、or2、or3、or4、or5、or6、or7、or8、or9、|| ~~~