On Aug 12, 2010, at 9:41 AM, Jigal sanders wrote:

Hi,

I realized that. I was just blinded by something. I am trying already two weeks to debug my application and something goes wrong with inserting data to my db from my form. And the problem is that:

1. It says in my screen An Error has ocurred.
2. No stack traces
3. No specific error messages in my error.log

Okay, I'd suggest trying to get some diagnostic output. It's hard to troubleshoot SQL when you look only at the code that generates dynamic SQL. Try outputting the final SQL string to stderr.

$sql = "INSERT INTO "
             . $this->quoteIdentifier($table, true)
             . ' (' . implode(', ', $cols) . ') '
             . 'VALUES (' . implode(', ', $vals) . ')';

error_log($sql, 0);

Also, I usually separate the prepare() from the execute(), even though I know query() does this for you. But it gives me the opportunity to detect where the error is happening. That is, if the error is in parsing the SQL, it'll happen in prepare(). If it's an error binding parameters or executing the prepared statement, it'll happen in execute().

$stmt = $this->prepare($sql);
$stmt->execute(array_values($bind));
$result = $stmt->rowCount();

Regards,
Bill Karwin

Reply via email to