N
N
Nikita Sokolov2020-05-17 22:59:55
PHP
Nikita Sokolov, 2020-05-17 22:59:55

How to execute two SQL commands at the same time through PDO?

Is it possible to execute such a request through PDO (myslqi is not suitable)?

CALL `GET_AVG_SALARY`(@p0); SELECT @p0 AS `result`;


Now it doesn't work for me. Writes SQLSTATE[HY000]: General error . In phpMyAdmin the result is correct.

In the php code itself, I have a class for working with data. It has a method that makes an PDO->prepare()incoming string (I don’t process the string in any way, so I would like to leave the prepare method) and just PDO->execute(). I use it for this request. But it doesn't work for my situation. I read about transactions and it doesn’t seem to work either, because they are not used to return values. Correct if not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-05-17
@wb_by

can

$pdo->query("CALL `GET_AVG_SALARY`(@p0)");
$pdo->query("SELECT @p0 AS `result`");

And for mysqli, this code is also suitable.

I
idShura, 2020-05-18
@idShura

Do it with a transaction

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question