Storing stored procedure in database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
raydona
Forum Newbie
Posts: 21
Joined: Sat Mar 21, 2009 9:17 am

Storing stored procedure in database

Post by raydona »

Hi,
How do I store a stored procedure in a database. I am using the following PHP code:
<html>
<body>
<?php
//connection string
$con = mysql_connect("host","username","password");
if(!$con)
{ die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);

$sqlStrProc = "CREATE PROCEDURE SomeName
(IN A VARCHAR(15),IN B VARCHAR(40),OUT C INT)
BEGIN
...........
END;";
mysql_query($sqlStrProc,$con);
mysql_close($con);
?>
</body>
</html>
I wonder if the above method is correct? Further, is there PHP code for checking whether a database is currently holding a stored procedure, function, trigger, etc.? If not what do I look for in the database server to find out if a stored procedure is being held? Many thanks for your help.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: Storing stored procedure in database

Post by novice4eva »

http://blog.techsaints.com/2008/07/22/l ... -in-mysql/

I use "toad" for mysql, its freeware and saves me a LOT of time for writing procedures and functions. You should try it.

http://www.quest.com/toad-for-mysql/
Post Reply