RE: How to Execute Multiple SQL Updates Using PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Alice Wei [mailto:ajwei@xxxxxxxxxxxxx]
> Sent: Wednesday, November 19, 2008 12:51 PM
> To: php-general@xxxxxxxxxxxxx
> Subject:  How to Execute Multiple SQL Updates Using PHP
> 
>   I am inquiring on this list to see if it is possible to create a
> script that takes multiple update statements without my having to
write
> one "SQL" statement for each of the updates.
> 
>   I have a scenario of which I create a table of some sort with some
> existing information using Flex, and what I am told by my client is
> that no matter how many records there are on the screen, the users
> should be able to update any up to all the entries by simply pushing a
> button. I use Microsoft SQL, which I think that it does allow multiple
> update query execution. The problem is that I might have to come up
> with some method to accept all the "POST" variables the user provides
> into the script.
> 
>    Could anyone please give me some guidance on what kind of function
I
> might use, or whether or not it is possible I can create a script that
> accepts as many "POST" variables as the users POST?
> 
> Thanks a lot for your help.

...sounds like more of a structure question than a PHP question, to be
honest. So, structurally speaking, I would build your app to name the
fields in a manner that is easily packaged and transported. That way,
you can just do a for-each loop on the $_POST array and extract them
using hints in your packaging method to tell which row and columns (and
values) are being placed in the SQL query. You can name your fields
something like "customerName[0]", "customerName[1]", etc., and PHP will
treat them as an array when they are unpackaged from the $_POST
parameters.

As for multiple SQL statements in one query, I don't see why creating a
TRANSACTION block with multiple statements (separated by a semicolon:
';') wouldn't be possible in PHP. I've never tried it personally, but
you are theoretically just passing your SQL server a query string--it
handles the rest. (Yes, it's a bit more complex than that... but that's
the brass tacks.)

HTH,


// Todd

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux