Calling stored procedure with MySQLi extension fails
Posted: Mon May 25, 2009 4:06 am
Hey all.
I've got a stored procedured in MySQL 5.1 called getposts. Below is its SQL code:
This stored procedure executes just fine from within MySQL, and returns the expected results.
However, when I call it up with the following code, it dies every time.
Although, if I use the SELECT statement from my stored procedure directly in the PHP code, it works.
Has anyone else run into this sort of issue and come across a solution?
I've got a stored procedured in MySQL 5.1 called getposts. Below is its SQL code:
Code: Select all
CREATE DEFINER=`root`@`localhost` PROCEDURE `getposts`()
BEGIN
SELECT
posts.post_id,
posts.post_title,
posts.post_body,
posts.post_created,
DATE_FORMAT (posts.post_created, '%M %d, %Y at %h:%i %p') AS post_date,
users.user_firstname,
categories.cat_name
FROM posts
INNER JOIN
users
ON
posts.author_fk = users.user_id
INNER JOIN
categories
ON
posts.cat_fk = categories.cat_id;
END
However, when I call it up with the following code, it dies every time.
Code: Select all
$mysqli = new mysqli('localhost','username','password','database');
$result = $mysqli->query("CALL getposts()") or die ('Could not run query');
Has anyone else run into this sort of issue and come across a solution?