chibineku Posted September 8, 2009 Share Posted September 8, 2009 I have several PHP scripts in my site, for example logging, logging out, adding items to your basket, etc. I was wondering what the arguments are in favour of, and against, using stored transactions. On the face of it, it seems like they might make things simpler, but is there any difference from just handwriting the code into a PHP script? Are there security concerns? Are there any real differences at all apart from the rollback feature? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 8, 2009 Share Posted September 8, 2009 Are you referring to stored procedures? I haven't heard of a stored transaction. Link to comment Share on other sites More sharing options...
chibineku Posted September 8, 2009 Author Share Posted September 8, 2009 Yes, that's the one. It all comes under the same chapter heading in the book I have. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 8, 2009 Share Posted September 8, 2009 Stored procedures are generally faster because they are compiled and optimized on the database. This is only database code though, you can't mess with the PHP session or read data from $_POST or whatever, it's basically just a function you define on the database to do several things instead of sending one or more queries. But since the database server compiles them they are faster than sending individual queries. Link to comment Share on other sites More sharing options...
chibineku Posted September 8, 2009 Author Share Posted September 8, 2009 Ah. Well, every query I make is dependent on variables from the session or POST, so not really any good to me. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 8, 2009 Share Posted September 8, 2009 You can still send the data to the SP, a SP is basically like a function on the database server, where you can still send it parameters. So you can't read the session data or post data inside the SP, but you can send that data to the SP through PHP. Link to comment Share on other sites More sharing options...
chibineku Posted September 8, 2009 Author Share Posted September 8, 2009 Ah, ok. Given your knowledge, from my many many threads, of my scripts, would you suggest implementing them? I believe for the moment I will leave well enough alone, but once the site is launched I can play around with things to improve efficiency. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 8, 2009 Share Posted September 8, 2009 If your database queries are taking a majority of the time and you have complex queries that need to run faster, it might be a good idea to use SPs. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.