Answer the question
In order to leave comments, you need to log in
How to call MS SQL stored procedure in Yii2?
Good afternoon! Tell me what I'm doing wrong when I call a stored procedure in Yii2? In MS SQL itself I call the procedure and it works: EXEC sp_GetRecipientPayments @user = 1, @sd= '2018-08-01', @ed='2018-08-03 ' . The @user data
types are int, @sd and @ed are datetime.
I write in the controller
$user = 1;
$sd = '2018-08-01';
$ed = '2018-08-03';
$command = Yii::$app->db->createCommand("CALL sp_GetRecipientPayments(:p_user,:p_start,:p_end)");
$command->bindParam(":p_user", $user, PDO::PARAM_INT);
$command->bindParam(":p_start", $sd, PDO::PARAM_STR);
$command->bindParam(":p_end", $ed, PDO::PARAM_STR);
$records = $command->queryAll();
return $this->render('index',compact('records'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question