How to call a stored procedure in Yii 2?

Hello
Trying to call the procedure in yii2:
$result = \Yii::$app->db->createCommand("CALL coverage_dis_prof(@r:prof :dis);SELECT @r;")
 ->bindValue(':prof' , 2)
 ->bindValue(':dis', 31)->execute();
 $r=(double)$result['r'];

The result is 0, although it should output something like 0.07...
In phpmyadmin the query displays exactly 0.07...
The procedure itself looks like this:
CREATE DEFINER = 'root'@'%'
PROCEDURE catalog.coverage_dis_prof(OUT double r, prof IN int, IN int dis)
BEGIN
 DECLARE allw int;
 DECLARE kd1 int;
 DECLARE kd2 int;
 DECLARE int kd;
 DECLARE k int;
SELECT
COUNT(action.id)
 FROM action,
workfunction,
general
 WHERE ACTION.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO allw;
SELECT
COUNT(own.id)
 FROM own,
action,
workfunction,
general
 WHERE own.id_discipline = dis
 AND own.id_sort = action.id
 AND ACTION.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof kd1 INTO;
SELECT
COUNT(ac_dis.id_discipline)
 FROM ac_dis,
action,
workfunction,
general
 WHERE ac_dis.id_discipline = dis
 AND ac_dis.id_action = action.id
 AND action.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO kd2;
SELECT
 kd1 + kd2 kd INTO;
SELECT
COUNT(ac_dis.id_discipline)
 FROM ac_dis,
action,
own
 WHERE ac_dis.id_action = action.id
 AND own.id_sort = action.id
 AND ac_dis.id_discipline = own.id_discipline INTO k;

SELECT
 kd - k INTO kd;
SELECT
 allw + COUNT(knowledge.id)
 FROM knowledge,
workfunction,
general
 WHERE knowledge.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO allw;
SELECT
COUNT(know.id)
 FROM know,
knowledge,
workfunction,
general
 WHERE know.id_discipline = dis
 AND know.id_sort = knowledge.id
 AND knowledge.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof kd1 INTO;
SELECT
COUNT(kn_dis.id_discipline)
 FROM kn_dis,
knowledge,
workfunction,
general
 WHERE kn_dis.id_discipline = dis
 AND kn_dis.id_knowledge = knowledge.id
 AND knowledge.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO kd2;
SELECT
 kd + kd1 + kd2 kd INTO;
SELECT
COUNT(kn_dis.id_discipline)
 FROM kn_dis,
know,
knowledge
 WHERE kn_dis.id_knowledge = knowledge.id
 AND know.id_sort = knowledge.id
 AND kn_dis.id_discipline = know.id_discipline INTO k;
SELECT
 kd - k INTO kd;
SELECT
 allw + COUNT(skill.id)
 FROM skill,
workfunction,
general
 WHERE skill.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO allw;
SELECT
COUNT(can.id)
 FROM can
skill,
workfunction,
general
 WHERE can.id_discipline = dis
 AND id_sort = skill.id
 AND id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof kd1 INTO;
SELECT
COUNT(id_discipline)
 FROM sk_dis,
skill,
workfunction,
general
 WHERE sk_dis.id_discipline = dis
 AND sk_dis.id_skill = skill.id
 AND skill.id_workfunction = workfunction.id
 AND workfunction.id_general = general.id
 AND general.id_profession = prof INTO kd2;
SELECT
 kd + kd1 + kd2 kd INTO;
SELECT
COUNT(sk_dis.id_discipline)
 FROM sk_dis,
can
skill
 WHERE sk_dis.id_skill = skill.id
 AND can.id_sort = skill.id
 AND sk_dis.id_discipline = can.id_discipline INTO k;
SELECT
 (kd - k) / allw INTO r;
END

What could be the problem?
March 23rd 20 at 18:47
1 answer
March 23rd 20 at 18:49
Solution
I found a solution.
If anyone is interested the solution is as follows:
$result = \Yii::$app->db->createCommand("CALL coverage_dis_prof(@r:prof :dis);")
 ->bindValue(':prof' , 2)
 ->bindValue(':dis', 31)->execute();
$rez=Yii::$app->db->createCommand("SELECT @r;")->queryScalar();
$r=(double)$rez;

Find more questions by tags YiiMySQL