catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

multi_query support #692

Closed KirDE closed 3 years ago

KirDE commented 6 years ago

Is there a support for multi_query mysqli function where multiple tables are returned as result? If running $medoo->query()->fetchAll(); only first table is returned

Andrews54757 commented 6 years ago

@KirDE Use SQL JOIN.

KirDE commented 6 years ago

@Andrews54757 i need two tables as result and they have completely different set of data. actually it is a procedure that is called. Currently we are doing it with new mysqli connection, but i don't like this solution.

Andrews54757 commented 6 years ago

@KirDE What do you mean? Please elaborate on what SQL procedure you want to do. What would be the query?

Lots of times, Multi-querying can be simply replaced with seperate queries.

The multi_query function is not in this library as it only applies to MySQL. In order to use with PDO, then it would be much harder.

If you still want to use PDO for multi-querying, then refer to this thread: https://stackoverflow.com/questions/6346674/pdo-support-for-multiple-queries-pdo-mysql-pdo-mysqlnd

KirDE commented 6 years ago

We have 2 SELECT Queries stored as single Procedure in mysql DB. We are not allowed to change this procedure to separate this queries.

Andrews54757 commented 6 years ago

@KirDE Oh, okay. Sorry, I thought you were meaning something else. Anyway, in your case you would have to use PDOStatement::nextRowset.

Andrews54757 commented 6 years ago

@KirDE There is a helpful resource here: https://www.ibm.com/support/knowledgecenter/en/SSSNY3_10.1.0/com.ibm.swg.im.dbclient.php.doc/doc/t0023501.html