Call to undefined method CI_DB_mysqli_result :: fetch_assoc ()

0

I use codeigniter and I want to traverse an array with a while but it gives me the following error

  

- > Call to undefined method CI_DB_mysqli_result :: fetch_assoc ()

while ($row=$mate->fetch_assoc()) {
                $mcID['mcID']=$row['mcID'];
                $mcID['mcNombre']=$row['mcNombre'];
            }

that's my while

    
asked by Soldier 10.07.2017 в 23:40
source

1 answer

0

Something similar happened to me some time ago, the issue was in the object on which I applied it because it is a bit different if you are doing a query using mysqli-> query or from mysqli-> prepare, in case of that is from a mysqli-> g prepare first you must obtain the result of the query to later perform the fetch_assoc

$mate = $prepare->get_result();
while ($row=$mate->fetch_assoc()) {  
  $mcID['mcID']=$row['mcID'];
  $mcID['mcNombre']=$row['mcNombre'];
}

I do not know if it is that but I tell you about my experience with that error.

Possible final solution

I checked the CodeIgniter reference and found this, apparently you should do $ mate-> _fetch_assoc (), I leave the web:

answered by 11.07.2017 в 03:33