tags:

views:

20

answers:

2

I'm testing some new code to insert into a MySQL database from using PHP. The test

$stmt->execute();
if ($stmt->errorCode() != 0)
{
    $arr = $stmt->ErrorInfo();
    throw new Exception('SQL failure:'.$arr[0].':'.$arr[1].':'.$arr[2]);
}

It threw a number of errors that I fixed one by one. Finally it dropped through, but nothing was written to the table. Is there any other test I can do or a log I could set up to see what the problem is? MySQL is running locally on my development PC.

Thanks for any help, Curt

P.S. The similar posting six months ago didn't suggest any further means of debugging that I could see.

A: 

You can activate MySQL's General Query Log and keep an eye on that log file.

VolkerK
I turned on the log and I see activity, but not when I execute my problem statement. Is it the case that MySQL sometimes doesn't report errors?
curt
Well I know of at least one error that it doesn't report. I failed to set the primary key field to auto-increment and didn't supply a value on the INSERT as would be the case had I done so.
curt
+1  A: 

I found an answer to my question, but am hoping for a better one. I copied the sql statement to phpMyAdmin SQL query window, substituted literals for all the variables, and ran it. I got an error 1426 IIRC, which deals with a foreign key mismatch. I got that error because the foreign key table was not innodb while the others were. Once I made that change in the DB, the query ran correctly. You would think that error would be returned in errorCode.

curt