I need to make a query to return only active records which in this case are imo_status
== 1
What is the best way to make this query? I'm using CI3
Below is the source code.
// LISTA OS AGENCIAMENTOS NO BANCO DE DADOS
public function getProperties()
{
$this->db->select('*');
$this->db->from('ci_properties');
$this->db->where('imo_status' == 1);
return $this->db->get("ci_properties")->result_array();
/*$query = $this->db->get("ci_properties");
return $query->result_array();*/
}
CodePudding user response:
You build the query then don't use it:
return $this->db->get("ci_properties")->result_array();
This wipes out the query builder and basically does a 'get all' from 'ci_properties'. To use you're query:
$query = $this->db->get();
return $query->result();
This is because you have already specified the table in the 'from' part, get('table name'), will get all.
CodePudding user response:
I solved this
public function getProperties()
{
$this->db->select('*');
$this->db->from('ci_properties');
$this->db->where('imo_status', 1);
$query = $this->db->get();
return $query->result_array();
}