MySQL Stored procedures
| From: | Tim Glen | Date: | Thu, 11 May 2006 16:58:51 +0000 |
| Subject: | MySQL Stored procedures | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-42489@lists.php.net to get a copy of this message | ||
Hey all,
I'm helping out a buddy with a project and his developer is using MySQL stored procedures.
He can use DB or MDB2 or whichever db package as he is still early in the process.
Assuming I have a $db object connected, and a $form object with my values, does this code basically look right?
/*
CALL vsp_InsertRegistration('Ripping Reapers','Tyler','Mitton','10804 Willowfern Dr SE','Calgary','AB','T2J 1R5','4036813210','tyler@mitton.ca',1, @out_intTeamEventDivisionID);
Requires:
arg_strTeamName VARCHAR(100)
arg_strContactFirstName VARCHAR(45)
arg_strContactLastName VARCHAR(45)
arg_strAddress VARCHAR(45)
arg_strCity VARCHAR(45)
arg_strProvince VARCHAR(45)
` arg_strPostalCode VARCHAR(7)
arg_strPhone VARCHAR(25)
arg_strEmail VARCHAR(100)
arg_intEventDivisionID INT
Returns:
out_intTeamEventDivisionID INT
-1 = one or more of the required paraments were null, this should be prevented by validators on the page, but if it happens, display: "Please provide all required fields."
-2 = the eventdivision they tried to register for doesn't exist, display: "Sorry, there has been an error in the registration process, please contact us at info@streethockeycanada.com."
-3 = the eventdivision they tried to register for was full, display: "Sorry, the division you selected is already full. Consider registering for a different division."
*/
$vals = $form->exportValues();
$str = "CALL vsp_InsertRegistration('%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d)";
$sql = sprintf($str, $vals['team_name'], $vals['first_name'], $vals['last_name'], $vals['address'], $vals['city'], $vals['province'], $vals['postal_code'], $vals['phone'], $vals['email'], $vals['event_division_id']);
$res = &$db->query($sql);
As I am just helping out my buddy, I don't have any access yet.
Thanks in advance for any help.
tim
--
tim glen
senior developer
nonfiction studios inc.
http://nonfiction.ca/
p 403 686 8887