Re: [PHP-DB] Stored Procedures, Dynamic SQL or static SQL and testing.
On Saturday, March 26, 2011, Richard Quadling wrote; What preferences do you all have when using SQL. Stored Procedures or PHP generated dynamic SQL or parameterized static SQL. Whichever you use how do you test them? Do you use unit testing in your PHP code? If so, do you also have unit code testing for the SQL statements (I suppose this mainly relates to SPs). Does using a different RDBMS make a difference to the SQL coding style you'd use? Personally, I prefer to use dynamic SQL and this doesn't really change no matter which RDBMS or programming language I use. I prefer doing it that way because it's easier to see what I've done (I don't need to interrogate the database to get procedure definitions, which aren't universally available) and I find it easier to debug because echoing p$query/p lets me see what I'm passing to the DB. I don't usually test SQL separately but as part of the application. However, when debugging I often copy the echoed query and then paste it into the CLI or other facility to check it returns what I expect. With all that said, sometimes I have no option but use a stored procedure. An example is where I'm inserting a new row and I need it's PK value (e.g. LAST_INSERT_ID() in MySQL). HTH, -- Geoff -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stored Procedures, Dynamic SQL or static SQL and testing.
On 2011-03-26, at 9:00 AM, Richard Quadling rquadl...@gmail.com wrote: Hi. What preferences do you all have when using SQL. Stored Procedures or PHP generated dynamic SQL or parameterized static SQL. I used both. SPs work for some of the larger reports, especially when combined with a view or two. For mist of the form interactions I tend to use regular SQL with prepared statements for simplicity and security Whichever you use how do you test them? Do you use unit testing in your PHP code? If so, do you also have unit code testing for the SQL statements (I suppose this mainly relates to SPs). Yes. I generally write and test the SQL before turning it into a SP Does using a different RDBMS make a difference to the SQL coding style you'd use? Generic SQL where possible. But occasionally I will use specific SQL for the RDBMS where appropriate. My current code base is not as layered as I would like to really make it a simple config switch to change the backend This isn't for any sort of thesis, just trying to see what the general consensus is of those that reply. Thanks for answering. Richard Quadling. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bastien Koert Sent from my iPhone -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stored Procedures vs mysqli_multi_query
Iulian Manea wrote: Hey everybody, Here is my problem: i have to exectute multiple SELECT queries to the database, ad my question is how it would be how it would be faster: How are you going to check for errors or whether the queries worked? If you run multiple queries in the same function call, how do you know which one failed? Answering your question, I have no idea - you'd probably be best setting up some tests. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stored Procedures ?
yep just call the name of your function as : SELECT MyFunction(); Ricardo Lopes wrote: Is possible to call database stored procedures from php with oracle or any other db? -- Alban Médici RD software engineer -- you can contact me @ : IPPhone : +33 (0)2 31 46 37 68 [EMAIL PROTECTED] http://www.netcentrex.net -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stored Procedures ?
That's fantastic. Thank you very much. - Original Message - From: Alban Médici (NetCentrex) [EMAIL PROTECTED] To: Ricardo Lopes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, January 19, 2004 9:58 AM Subject: Re: [PHP-DB] Stored Procedures ? yep just call the name of your function as : SELECT MyFunction(); Ricardo Lopes wrote: Is possible to call database stored procedures from php with oracle or any other db? -- Alban Médici RD software engineer -- you can contact me @ : IPPhone : +33 (0)2 31 46 37 68 [EMAIL PROTECTED] http://www.netcentrex.net -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stored Procedures ?
Ricardo Lopes wrote: Is possible to call database stored procedures from php with oracle or any other db? There is a complete Oracle example in Frank Naudé's Oracle/PHP FAQ: http://otn.oracle.com/tech/opensource/php_faq.html#PROC Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] stored procedures on mssql
Use mssql_bind -- bob On Mon, 5 Jan 2004, Filipe Girafa wrote: Hi, how do i pass the arguments to the db when using the mssql_execute function? thanks, Filipe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php