基本上,这就是我想要做的,它是如何工作的?
public function get_product_category(){
$id = $this->uri->segment(3);
$query = $this->db->query('SELECT * FROM products where category_id = $id ');
return $query->row();
}
您可以使用查询生成器类
public function get_product_category(){
$this->db->where('category_id', $this->uri->segment(3));
$query = $this->db->get('products');
return $query->row();
// return $query->row_array();
}
或者
public function get_product_category(){
$this->db->select('*');
$this->db->from('products');
$this->db->where('category_id', $this->uri->segment(3));
$query = $this->db->get();
return $query->row();
// return $query->row_array();
}
我会自动加载数据库库。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句