-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support stored procedures (multiple result sets) #171
Comments
@drucifer Thanks for reporting, I can confirm that calling stored procedures using the The reason for this is that stored procedures may contain multiple statements and as such may return multiple results and our query API is not really suited for exposing multiple possible results. In other words, what kind of data structure would you expect the following stored procedure to return? DELIMITER //
CREATE PROCEDURE not_so_simple()
BEGIN
SELECT …;
UPDATE …;
SELECT …;
END;
// In this case, we may want to expose an array(?) of In your original example, your stored procedure only returns a single result set, so we would be able to expose this using our existing APIs, but the question would remain what would be supposed to happen if the stored procedure would return multiple result sets. From a technical perspective, this boils down to specifying the I suppose we're happy to accept PRs that implement support for this or if you need this for a commercial project and you want to help sponsor this feature, feel free to reach out and I'm happy to take a look. Other than that, there are currently no immediate plans to build this from my end (no demand at the moment and more important outstanding issues currently). Let us know if you're interested in sponsoring this or want to work on this yourself 👍 |
I suspected that was the reasoning, but wanted to confirm that this was an intentional omission and not just an oversight, as I did not see it mentioned or documented. It is not a high priority for us at the moment - our current PHP applications do not make heavy use of stored procedures, as the legacy mysql_query() had a similar limitation. However, we had been hoping to move in that direction as we uplift some of our older codebases, as many other applications in our company use stored procedures almost exclusively. From an API perspective, I think the cleanest way would be to make QueryResult into a linked list with a '->nextResult' pointer to another QueryResult. This avoids creating a function that might return one object or might return an array of objects depending on how it is called. It would still be compatible with the existing API, and essentially transparent to anyone that isn't specifically expecting multiple results. If that is an acceptable API change for you, I can look into creating a pull request in the future if we decide that this is important for us. I can ask about sponsorship as well. We have done it in the past for other open source projects. |
Definitely interested in support for stored procedures for this project! I like your idea of using a linked list of |
Using the To reproduce (examples/01-query.php): $userInfo = await($connection->query('CALL simple_select();'));
print_r($userInfo->resultRows);
$settings = await($connection->query('SELECT * FROM settings;'));
print_r($settings->resultRows); Error log:
|
@devblack You see this output, because it's currently not supported by this project. I think this is the behavior @clue described above:
Just patching the source code without the feature itself supported will end up in an error, so setting this flag currently doesn't make much sense. I think once we support calling stored procedures using the |
Calling a stored procedure results in an error:
To reproduce, define a simple MySQL stored procedure:
In PHP:
The text was updated successfully, but these errors were encountered: