0
I’m trying to put a condition in a function and it’s not working...
I tried to put this condition but it didn’t work $this->db->where('idUser =', $this->session->userdata('id'));
Usually all condition do as the code below, but only this that did not work.
function get($table, $fields, $where = '', $perpage = 0, $start = 0, $one = false, $array = 'array')
{
$this->db->select($fields.', clientes.nomeCliente, clientes.idClientes');
$this->db->from($table);
$this->db->limit($perpage, $start);
$this->db->join('clientes', 'clientes.idClientes = '.$table.'.clientes_id');
$this->db->order_by('idVendas', 'desc');
$this->db->where('idUser =', $this->session->userdata('id'));
if ($where) {
$this->db->where($where);
}
$query = $this->db->get();
$result = !$one ? $query->result() : $query->row();
return $result;
}
Utilizes
print_r($this->db->last_query());
for you to have theSQL
of that query and check if it is correct and works directly in the bank.– Kayo Bruno
Perhaps on account of
join
you need to specify which field tableidUser
, for example:$this->db->where('nomeDaTabela.idUser =', $this->session->userdata('id'));
– Kayo Bruno