php PDO fetchAll() - while not working, foreach works

后端 未结 5 1092
感动是毒
感动是毒 2020-12-11 16:37

I would like to know if i\'m doing fine OR fetchAll() doesn\'t work with WHILE.

here is an exemple

$db=new PDO(\"mysql:host=\" .$dbhost. \"; dbname=\         


        
5条回答
  •  醉话见心
    2020-12-11 17:29

    With fetchAll In while loop you have fetched all records in the first iteration and there is nothing to fetch the next time. In foreach also you have fetched all records in the first line, but foreach uses the result for iteration.

提交回复
热议问题