SQL Procedures and Functions

Post here if you need help with SQL.
Post Reply
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

SQL Procedures and Functions

Post by bowersbros »

If i were to make a SQL function or procedure, I assume I can store it in a seperate file (most likely .sql file) but how would i go about including it, and calling the function etc?
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: SQL Procedures and Functions

Post by jacek »

I'm not sure it's possible in a nice way, you can do a shell_exec as described here http://stackoverflow.com/questions/4027 ... les-in-php but that will open new connection for every query (slow) and uses shel_exec (slower).

Not tried, but could you do
mysql_query(file_get_contents('thingy.sql'));
?
Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: SQL Procedures and Functions

Post by bowersbros »

Apparently
mysql_query('call procedure_name()'); 
Will work
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply