I am trying to execute the following code in laravel...
$sql = "SET @p0='$p_id'; CALL `rating_avg`(@p0);";
$pp = mysqli_query($link,$sql);
if($pp == false)die("QUERY DIDN'T EXECUTE");
But always showing QUERY DIDN'T EXECUTE
I am doing a web project using Laravel. My project name is Research paper management system. Our course teacher forbid us to use laravel model and told us to execute any query in the following way. $sql = "SOME QUERY"; mysqli($database_connect , $sql);
That's why I am trying to do the following as our teacher's terms and conditions...
$sql = "SET @p0='$p_id'; CALL `rating_avg`(@p0);";
$pp = mysqli_query($link,$sql);
if($pp == false)die("QUERY DIDN'T EXECUTE");
Here 'rating_avg' is a procedure. I have created it manually in the phpMyadmin database. While creating I found the following query...
CREATE PROCEDURE `rating_avg`(IN `pid` INT) DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER select avg(reviewer_given_rating) AS v from paper_has_reviews where paper_id=pid;
Everything is okay. I just don't know how to run the query
$sql = "SET @p0='$p_id'; CALL rating_avg(@p0);";
mysqli_query() isn't working here.