E
E
Eugene Chronos2019-10-21 21:10:10
Yii
Eugene Chronos, 2019-10-21 21:10:10

Where to place calls to stored procedures in yii?

For work with tables I use ActiveRecord. But the inheritance inherited a base in which part of the work with tables goes through procedures. How/where is it architecturally best to place calls to stored procedures in the code? And how to work if, for example, part of the queries to the table will go through the ORM, and part through the procedures?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2019-10-21
@XPOHOC69

Use the repository and write there even in SQL, even in AR
And already there you call something like this:

$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();

V
vitaly_74, 2019-10-21
@vitaly_74

Use the adapter pattern - it will help you solve your problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question