PHP PDO with foreach and fetch

后端 未结 4 1924
我在风中等你
我在风中等你 2020-12-01 16:31

The following code:



        
4条回答
  •  渐次进展
    2020-12-01 16:38

    This is because you are reading a cursor, not an array. This means that you are reading sequentially through the results and when you get to the end you would need to reset the cursor to the beginning of the results to read them again.

    If you did want to read over the results multiple times, you could use fetchAll to read the results into a true array and then it would work as you are expecting.

提交回复
热议问题