php 调用带返回多个结果集的方法,PHP中有多个结果集?
在.NET中,SqlDataReader可以檢索多個記錄集:
Dim Connection As New SqlConnection(SomeConnectionString)
'Note that the command will generate three result
Dim Command As New SqlCommand("select '1a', '1b'; " & _
"select '2a', '2b', '2c'; " & _
"select '3a', '3b'; ", Connection)
Dim Reader As SqlDataReader
Connection.Open()
Reader = Command.ExecuteReader
Do
While Reader.Read
'Do something with the data
End While
Loop While (Reader.NextResult) 'Proceed to next result
Reader.Close()
Connection.Close()
.NextResult將閱讀器移至下一個結果.如何在PHP中做到這一點?我基本上想避免多次往返數據庫.
注意:.Read這里移動下一行,而.NextResult移動到下一個結果.
1個查詢,3個結果:
結果1
1a 1b
結果2
2a 2b 2c
結果3
3a 3b
注意:行不等于結果.結果更像是一個表或一組行.
解決方法:
如果您正在使用PDO,則可以通過使用PDOStatement->nextRowset()來執行此操作.是否支持此功能完全取決于您要連接的數據庫以及所使用的PDO驅動程序.
標簽:resultset,php
來源: https://codeday.me/bug/20191208/2088414.html
總結
以上是生活随笔為你收集整理的php 调用带返回多个结果集的方法,PHP中有多个结果集?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 表.t_mysql ---表
- 下一篇: php 智能输入提示插件,PHP结合jQ