RE: Multiple inserts as a single string?

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

 



Thomas,

I am not sure what database you are using, but there was a previous email
thread about using execQuery($concatstring) for mySQL, which apparently
worked. Make sure that your insert statements end with the standard line
terminator character, usually ';'.

Personally, I would output the statements to a file, then use the cmd line
function for executing .sql files for that database. You could execute this
from php by using the shell_exec function. This is so I could look at the
executed sql file and find where the error is, I'm not a big fan of debugging
in php.

C.

-----Original Message-----
From: Thomas [mailto:tomatosh@xxxxxxxxx]
Sent: 02 June 2005 12:20
To: Shaw, Chris - Accenture
Cc: php-general@xxxxxxxxxxxxx
Subject: RE:  Multiple inserts as a single string?


*************************************

This e-mail has been received by the Revenue Internet e-mail service.

*************************************

Hi Chris,

Thanks, I thought so. You are quite right with the errors, I ran into some
where it looked like that php does not allow you to execute such a concated
string ... the error started at the second insert statement with no apparent
reason. Is that a ph restriction?

Thomas

-----Original Message-----
From: Shaw, Chris - Accenture [mailto:cshaw@xxxxxxxxxx]
Sent: 02 June 2005 12:20 PM
To: Thomas; php-general@xxxxxxxxxxxxx
Subject: RE:  Multiple inserts as a single string?


Thomas,


If you're inserting alot of rows, (eg millions) then concating them and
calling the db once probably would give a small speed advantage, because of
the database handshaking.
But I would look at the load the database is under, if there is alot of
users
hitting the database with small inserts/queries then the database is going
to
suffer as opposed to the same number of users hitting the database once with
a script.

The only problem I can think of, from php (client) point of view, if the
script (concated inserts) errors, then you will need to handle where it went
wrong, if it was loop, you know exactly what went wrong by outputing the
current insert statement.

C.

-----Original Message-----
From: Thomas [mailto:thomas.hochstetter@xxxxxxx]
Sent: 02 June 2005 10:20
To: php-general@xxxxxxxxxxxxx
Subject:  Multiple inserts as a single string?


Hi there,




I have a bit of strange question: when wanting to insert multiple records
into the db, instead of looping through the set and executing mysql_query
(which will then call the db n times), is it not better to concat a string
with all the insert statements and let mysql handle the inserting, that way
we don't call the db n times from php. Does that make any difference?

Maybe I am just stupid .




Thomas




************************

This message has been delivered to the Internet by the Revenue Internet
e-mail service

*************************

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





************************

This message has been delivered to the Internet by the Revenue Internet e-mail service

*************************

-- 
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