Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel中编写这种类型的查询?_Php_Codeigniter_Laravel_Laravel 4 - Fatal编程技术网

Php 如何在laravel中编写这种类型的查询?

Php 如何在laravel中编写这种类型的查询?,php,codeigniter,laravel,laravel-4,Php,Codeigniter,Laravel,Laravel 4,这是Codeiginter活动记录查询我如何在Laravel-4查询中编写它 public function bring_project_sub_sector5($id = 0) { if ($id != 0) { $this->db->select("t2.sector_name_en AS sub_sector_name"); $this->db->from("biz_r_proj_activity AS t1, biz

这是Codeiginter活动记录查询我如何在Laravel-4查询中编写它

    public function bring_project_sub_sector5($id = 0) {
    if ($id != 0) {
        $this->db->select("t2.sector_name_en AS sub_sector_name");
        $this->db->from("biz_r_proj_activity AS t1, biz_s_sub_sector AS t2");
        //$this->db->join("biz_s_sub_sector AS t2","t2.id = t1.sub_sector_id","left");
        $this->db->where("t1.sub_sector_id = t2.id");
        $this->db->where("t1.id", $id);
        $this->db->group_by('t2.id');
        $query = $this->db->get();
        if ($query) {
            return $query;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}

类似这样,假设你没有那张桌子的模型

$query = DB::table('biz_r_proj_activity AS t1')
            ->join('biz_s_sub_sector AS t2', 't1.sub_sector_id', '=', 't2.id')
            ->where('t1.id', $id)
            ->groupBy('t2.id')
            ->get(array('t2.sector_name_en AS sub_sector_name'));