I have the following query in SQL
that works fine
SELECT MONTH(NOW()) AS mes, SUM(importe) as monto FROM pago_cliente WHERE MONTH(fecha_del_deposito) = MONTH(NOW()) AND YEAR(fecha_del_deposito) = YEAR(NOW()) GROUP BY 1
And I try to transform it in such a way so that it is a successful query in PHP, I use codeigniter for this and I have the following:
public function rowCountPagos($tabla)
{
$this->db->select("MONTH(fecha_del_deposito) as mes, SUM(importe) as monto");
$this->db->from($tabla);
$this->db->where("fecha_del_deposito = MONTH(NOW()) AND YEAR(fecha_del_deposito) = YEAR(NOW())");
$this->db->group_by("1");
$resultados = $this->db->get();
return $resultados->result();
}
But I can not get it to work and I find the following message
"Message: Undefined offset: 0"
any help with this? I thank you in advance.