• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter - Mysql: Invalid argument supplied for foreach()

#1
[eluser]Unknown[/eluser]
Code:
function countSv_AV_total(){

    $this->db->flush_cache();
    $this->db->start_cache();

   $sql = "select Verzekeringen.naam,\n"
    . " count(*) total,\n"
    . " sum(case when (Age <= 18) then 1 else 0 end) Age18,\n"
    . " sum(case when (Age BETWEEN 19 AND 30) then 1 else 0 end) Age19,\n"
    . " sum(case when (Age BETWEEN 31 AND 50) then 1 else 0 end) Age30,\n"
    . " sum(case when (Age BETWEEN 51 AND 69) then 1 else 0 end) Age50,\n"
    . " sum(case when (Age >= 70) then 1 else 0 end) Age70\n"
    . " from customers\n"
    . " INNER JOIN Verzekeringen\n"
    . " ON customers.AV=Verzekeringen.verzekeringcode\n"
    . " AND Label =1\n"
    . " group by Verzekeringen.naam LIMIT 0, 30 ";

$this->db->query($sql);

    echo $this->db->last_query().'<br />';

    return $this->db->count_all_results('customers','Verzekeringen');
    $this->db->flush_cache();

}

I'm using this SQL and in the Mysql workbench it's given the right output. Now I want this to get this to the codeigniter Table class.

I get an error while foreach is not recieving data:

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/welcome_message.php

Line Number: 178

Can somebody provide an solution. Thanks in advance


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.