ThinkPHP的数据库查询

来源:互联网 发布:淘宝卖家客服怎么分流 编辑:程序博客网 时间:2024/05/16 08:26
    $User = M("User"); // 实例化User对象    $condition['name'] = 'thinkphp';    $condition['status'] = 1;    // 把查询条件传入查询方法    $User->where($condition)->select(); 


最后生成的SQL语句是

  1. SELECT * FROM think_user WHERE `name`='thinkphp' AND status=1

$User = M("User"); // 实例化User对象$condition['name'] = 'thinkphp';$condition['account'] = 'thinkphp';$condition['_logic'] = 'OR';// 把查询条件传入查询方法$User->where($condition)->select();
最后生成的SQL语句是

  1. SELECT * FROM think_user WHERE `name`='thinkphp' OR `account`='thinkphp'

原创粉丝点击