How to call Mysql stored procedure with parameters in Yii PHP Framework:
Mysql Stored Procedure:
Mysql Stored Procedure:
drop procedure if exists sp_getstudentdetails;
DELIMITER $$
CREATE PROCEDURE sp_getstudentdetails(
in p_mode varchar(100))
BEGIN
IF p_mode = 'view' THEN
select * from student;
END IF;
END$$
DELIMITER $$
PHP:
$mode = 'view';
$command = Yii::app()->db->createCommand("CALL sp_getstudentdetails(:p_mode)");
$command->bindParam(":p_mode", $mode, PDO::PARAM_INT);
$data = $command->queryAll();
(or)
$command = Yii::app()->db->createCommand("CALL sp_getstudentdetails(:p_mode)");
$data = $command->
->queryAll(array(':p_mode' => $mode));
Related Links:
Get multiple result sets from Mysql stored procedure in Yii PHP Framework
After executing this am getting IF THEN syntax error in my stored procedure....
ReplyDeleteI have read your blog its very attractive and impressive. I like it your blog.
DeletePHP 7 Training in chennai | PHP 7 Training Course
PHP 7 Training in chennai | Online PHP 7 Course
Please Help me to solve this Error....
ReplyDelete