SELECT * FROM table;
SELECT * FROM table1;
Out $id;
As above: The stored procedure returns two result sets and one output parameter, how do you get both result sets and output parameters in PHP?
Reply to discussion (solution)
Read
See Pdostatement::nextrowset method description
Read
See Pdostatement::nextrowset method description
If there are only multiple collections I know, but there are output parameters, as follows
$stmt = $db->prepare ("Call Pro_test (: Name, @sp_result);"); $stmt->execute (Array (': Name ' = $name)), $outputArray = $db->query ("select @sp_result")->fetch (PDO:: FETCH_ASSOC);p Rint_r ($outputArray ["@sp_result"]);
The stored procedure returns a collection, and the output parameter needs to be queried once, but in this step there is an error.
$outputArray = $db->query ("select @sp_result")->fetch (PDO::FETCH_ASSOC);
Error:soap-env:server, String:call to a member function fetch () on a non-object
I guess it should be. Before the stored procedure returned a result, another one on the error, how to solve?
This is an example from the manual.
$sql = ' Call Multiple_rowsets () '; $stmt = $conn->query ($sql); $i = 1;do { $rowset = $stmt->fetchall (pdo_fetch_ NUM); if ($rowset) {//Think about why you should first Judge Printresultset ($rowset, $i); } $i + +;} while ($stmt->nextrowset ());
This is an example from the manual.
$sql = ' Call Multiple_rowsets () '; $stmt = $conn->query ($sql); $i = 1;do { $rowset = $stmt->fetchall (pdo_fetch_ NUM); if ($rowset) {//Think about why you should first Judge Printresultset ($rowset, $i); } $i + +;} while ($stmt->nextrowset ());
You may have misunderstood me, I need the result set of the stored procedure and the parameters returned by the stored procedure, but have been solved, or go to the official website to see, thank you for your attention, • There's a lot of questions back there.
Note for mysql:to use input/output parameters for stored procedures with PDO use PDO. Query () statement. For example:
query ("CAST somestoredprocedure ($someInParameter 1, $someInParameter 2, @someOutParameter)"); $ Dbh->query ("select @someOutParameter");?> or, if you want very much to the use PDO. Prepare (), insert "Select @someOutParameter" in your stored procedure and then use:
Prepare ("CAST Somestoredproc Edure (?,?) "); $stmt->execute (Array ($someInParameter 1, $someInParameter 2));?>