Procedure
delimiter $$
drop procedure if exists db1.test;
create procedure db1.test()
deterministic
begin
select * from table1;
end$$
delimiter ;
php code:
$conn = new mysqli('localhost','username','passwd','db1');
$query1 = 'select * from table1';
$query2 = 'call test()';
Then $conn->query($query1) works while $conn->query($query2) returns bool(false).
But in mysql, both query1 and query2 work.
What did I miss here? Thanks!
Okay, if it’s not the syntax, it could be permissions. Did you grant execute privileges to the user for this database?
Edit:
Here’s the SQL to do this:
(Even if a user has all the permissions required to do the SQL inside the stored procedure as individual queries, you’d still need the EXECUTE privilege to actually call the procedure.)