MySQL Forums
Forum List  »  PHP

Re: Calling MySQL(5) Stored Procedures from PHP(5)
Posted by: Johny Pukhrambam
Date: August 28, 2006 05:51AM

//Say following is the store procedure you have

DELIMITER //
DROP PROCEDURE IF EXISTS yourdbname.gsp_GetCountryList //
CREATE PROCEDURE yourdbname.gsp_GetCountryList()
BEGIN
SELECT Id,strCountryName from youtable;
END//

//the above has to be run on mysql prompt


//change the php variables according to your setting

<?php
function iconnect()
{
$mysqli = new mysqli($YOURHOST, $YOURUSERNAME, $YOURPASSWORD, $YOURDATABASE);

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
return $mysqli;
}

$retval=iconnect();

$sql1 = "call sp1()";
$query1 = $retval->query($sql1);
while ($data1 = $query1->fetch_row())
{
echo "<br />\n".$data1[0].":".$data1[1];
}

//*************OR*****************


$sql1 = "call sp1()";
$query1 = $retval->query($sql1);
$data1 = $query1->fetch_row();
while ($data1 = $query1->fetch_array())
{
echo "<br />\n".$data1['fiendname1'].":".$data1['fiendname2'];
}
?>


Hope this will help you!!!!! NJOI

Options: ReplyQuote


Subject
Written By
Posted
Re: Calling MySQL(5) Stored Procedures from PHP(5)
August 28, 2006 05:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.