2012-11-14 7 views
5

Nel mio script PHP che esegue un'istruzione UPDATE come segue:Come ottenere maggiori informazioni su questo errore MySQL DOP con Zend

$this->_db->update('names', $data, $this->_db->quoteInto('id = ?', $obj->id)); 

Il manico db è un'istanza Zend_Db_Adapter_Abstract (della varietà DOP MySql).

Il problema è che l'aggiornamento non funziona e non riesco a ottenere più informazioni sull'errore.

L'errore si verifica all'interno di un blocco try/catch. Quando prendo l'errore, corro:

$db->getProfiler()->getLastQueryProfile(); 

e l'uscita è:

2012-11-14T22:20:02+11:00 INFO (6): Zend_Db_Profiler_Query Object 
(
    [_query:protected] => begin 
    [_queryType:protected] => 64 
    [_startedMicrotime:protected] => 1352892002.6064 
    [_endedMicrotime:protected] => 1352892002.6066 
    [_boundParams:protected] => Array 
     (
     ) 

so che dice parametri sono legati, ma io davvero non credo che sia il caso. Penso che in qualche modo "l'ultima query" non sia ciò che penso sia.

In secondo luogo, quando prendo l'errore Ho anche eseguire:

$db->getConnection()->errorInfo(); 

e l'uscita è:

2012-11-14T22:20:02+11:00 INFO (6): Array 
(
    [0] => 00000 
    [1] => 
    [2] => 
) 

Ovviamente questo non è molto utile.

Qualche idea? Come posso ottenere maggiori informazioni sull'errore?

Grazie!

risposta

1

È possibile forzare DOP per generare eccezioni con tutte le informazioni:

<?php 

$this->_db->->getConnection()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 


try { 
    $this->_db->update('names', $data, $this->_db->quoteInto('id = ?', $obj->id)); 
} 
catch (Exception $ex) { 
    print_r($ex); 
} 
+0

Nice one Ivan, grazie. –