Error in returning a SQL query with INNER JOIN in PHP, missing elements in the array that receives Query result

0

I'm having a problem in receiving the result of a query in an array, when I query the database the result I want works perfectly, but at the time of saving in the array in php it returns only one line that is not any of the lines of the query, but for a query without the INNER JOIN the result comes out as expected, I think the problem is time to validate in array_key_exists ('initial_time', $ data) :

1. Code in which error occurs:

  • The model code in php:

public function chart_report_bolsas_por_ano_row ($ start_date, $ data_final) {

$sql = "
    SELECT YEAR( b.data_vigencia_inicial ) AS ano, COUNT( i.cod_bolsa ) AS bolsas, COUNT( i.cod_bolsa ) AS label,  ? AS color
    FROM  'indicacao' AS i
    INNER JOIN bolsa AS b ON i.cod_bolsa = b.cod_bolsa
    WHERE b.data_vigencia_inicial
    BETWEEN  ?
    AND  ?
    GROUP BY YEAR( b.data_vigencia_inicial )   ";
$query = $this->db->query($sql,array("'color: #b3d9ff'",$data_inicio, $data_final));
$rows = $query->result();
if (empty($rows)){
    return array("status"=>"error","message"=>"Erro ao carregar intervalo de ano de vigência inicio");
}else{
    return $rows;
}
  • Result returned by the browser using a range from 01/10/2010 to 01/01/2018:

    [

asked by anonymous 26.02.2018 / 17:52

0 answers