选择所有相应的数据

ghg1uchk  于 2021-06-16  发布在  Mysql
关注(0)|答案(1)|浏览(199)

我想选择所有的产品与该品牌标识,但只有一个是来。
型号代码

public function get_product_by_brid($id)    {       
  $this->db->select('*');
  $this->db->from('product p'); 
  $this->db->join('category c', 'c.CategoryId=p.CategoryId', 'left');
  $this->db->join('brand s', 'p.BrandId=s.BrandId', 'left');             
  $this->db->where('p.BrandId',$id);        
  $query  $this->db->get();
  return $query->row();     
}

控制器代码

public function ajax_delete($id)
{
    $brand = $this->brand->get_by_id($id);

    $productsunderbrand = $this->brand->get_product_by_brid($id);
    echo "<pre>";
    print_r($productsunderbrand);
    exit();
    $this->brand->delete_by_id($id);
    echo json_encode(array("status" => TRUE));
}
s4n0splo

s4n0splo1#

return $query->row();

返回行只返回一个结果。
尝试

return $query->result();

return $query->result_array();

相关问题