Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > logging of sql queries - success/failed
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 15th March 13:07
dave.bosky
External User
 
Posts: 1
Default logging of sql queries - success/failed



I've got a script that imports several CSV files via the Load Data File
command.

I need to know if each import query was successful or failed.

Is there a way to log the success/failure of each query including how
many rows were inserted?

Thanks,
Dave


************************************************** ********************
HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.
************************************************** ********************
  Reply With Quote


  sponsored links


2 15th March 13:08
jmoseby
External User
 
Posts: 1
Default logging of sql queries - success/failed



I assum you are using MySQL, since you didn't specify. Typically,
mysql_query() will return false if the query failed, and
mysql_affected_rows() will return the number of rows affected.

JM
  Reply With Quote


  sponsored links


3 15th March 19:53
ceo
External User
 
Posts: 1
Default logging of sql queries - success/failed


I don't think so, but MAYBE mysql_affected_rows would return that data...

If any of the rows fail, I'd expect the mysql_error() would have some
kind of error message in it, and your result would be === false, I
think.

Another option would be to do a select count(*) before and after, and
subtract the difference. You could also compare that to the number of
lines in the file, and "know" if it all went okay.

Wrap it all in a transaction, if there's any chance another process
could be adding/deleting rows at the same time.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666