1、

http://www.mobanstore.com/doc/bianchengkaifa/119.html

//初学laravel 发现他的查询构造器很好用
//如下
$user = DB::table('users')->where('name', 'John')->first();
var_dump($user->name); //但是 如果where里面有多个查询条件怎么办呢? 我查了查源码 原来是可以用数组的,这样就灵活多了 public static function article_data($id)
{
  //$id = Input::get('id');
  $where = array('a.id' => $id, 'a.rm'=>0); // 关键是这里
  $data = DB::table('article AS a')
    //->where('a.id', '=', $id)
    ->where($where)
->leftJoin('category AS b', 'a.catid', '=', 'b.id')
->select('a.*', 'b.name AS catname', 'b.id AS catid' )
->get();   if($data)
  {
    return $data[0];
  }
  //$sql = DB::getQueryLog();
  //var_export( $sql);die; }

2、

http://www.cnblogs.com/yjf512/p/4031782.html

//解决办法:在基类中扩展一个multiwhere
//于是我就在BaseModel中定义了: // 多where
public function scopeMultiwhere($query, $arr)
{
if (!is_array($arr)) {
return $query;
} foreach ($arr as $key => $value) {
$query = $query->where($key, $value);
}
return $query;
} //这样子,上面的语句就可以这么使用:
Student::multiwhere([‘female’=>1, ’teacher_id’ => 4, ‘class_id’ => 3])->get();

laravel where中多条件查询的更多相关文章

  1. C# 将Access中时间段条件查询的数据添加到ListView中

    C# 将Access中时间段条件查询的数据添加到ListView中 一.让ListView控件显示表头的方法 在窗体中添加ListView 空间,其属性中设置:View属性设置为:Detail,Col ...

  2. Hibernate中的条件查询完成类

    Hibernate中的条件查询有以下三个类完成: 1.Criteria:代表一次查询 2.Criterion:代表一个查询条件 3.Restrictions:产生查询条件的工具类

  3. SSM-MyBatis-13:Mybatis中多条件查询

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 实体类 public class Book { private Integer bookID; private ...

  4. ormlite 在android中 排序 条件查询

    ormlite 在android中 排序 条件查询 all = dao.queryBuilder().orderBy("Id", true).where().eq("Ty ...

  5. Hibernate中的条件查询完毕类

    Hibernate中的条件查询有下面三个类完毕: 1.Criteria:代表一次查询 2.Criterion:代表一个查询条件 3.Restrictions:产生查询条件的工具类

  6. ThinkPHP中 按条件查询后列表显示

    最近在项目中遇到了需要根据下拉框的条件筛选出符合条件的数据,然后进行列表显示的问题. 在ThinkPHP中进行列表显示的传统过程:通过在后台控制器中查询出数据,然后通过$this->assign ...

  7. SQL中多条件查询括号的用途

    界面: 代码 0 posted @ 2009-12-15 13:28 唔愛吃蘋果 阅读(8640) 评论(0)  编辑 收藏

  8. 【.Net】C# 将Access中时间段条件查询的数据添加到ListView中

    一.让ListView控件显示表头的方法 在窗体中添加ListView 空间,其属性中设置:View属性设置为:Detail,Columns集合中添加表头中的文字. 二.利用代码给ListView添加 ...

  9. Mybatis-技术专区-中的条件查询createCriteria example里面的条件

    之前用Mybatis框架反向的实体,还有实体里面的Example,之前只是知道Example里面放的是条件查询的方法,可以一直不知道怎么用,到今天才开始知道怎么简单的用. 在我们前台查询的时候会有许多 ...

随机推荐

  1. 【设计模式】策略模式 (Strategy Pattern)

    策略模式是一种很简单的基础模式,用于封装一系列算法,使客户端的访问独立于算法的实现.我们可以”井中取水”来形象的描述策略模式.“取水”是一个动作,完成这个动作的方式有很多中,可以直接用手提.可以用水车 ...

  2. C语言接口的写法(以toyls命令为例)

    #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h&g ...

  3. Android JNI如何调用第三方库

    http://www.2cto.com/kf/201504/388764.html Android JNI找不到第三方库的解决方案 cannot load library 最近做一个jni项目,拿到的 ...

  4. asp.net实现手机号码归属地查询,代码如下

    protected void Button1_Click(object sender, EventArgs e)        {            if (Regex.IsMatch(TextB ...

  5. Windows Phone中In-App Purchase应用内购买

    前言       应用内购买(In-App Purchase)对于开发者来说绝对是一个非常重要的功能,它提供了一个便捷的入口供用户来购买付费.在IAP盛行之前的游戏运营商一般都是通过接入第三方支付入口 ...

  6. swift 基于SDK8.0 获取当前时间

    var date = NSDate.date() var timeFormatter = NSDateFormatter() timeFormatter.dateFormat = "MM-d ...

  7. js 获取字符串中最后一个斜杠后面的内容

    var str = "/asdasf/asfaewf/agaegr/trer/rhh"; var index = str .lastIndexOf("\/"); ...

  8. Json.Net使用JSON Schema验证JSON格式

    Json.NET supports the JSON Schema standard via the JsonSchema and JsonValidatingReader classes. It s ...

  9. 容器适配器之stack

    参见http://www.cplusplus.com/reference/stack/stack/ template<class T, class Container = deque<T& ...

  10. Struts2重定向

    第一方式:  参数之间必须使用&   .&是&在xml中转义字符  <result name="error" type="redirect& ...