Welcome Guest, Not a member yet? Register   Sign In
Catch DB error
#4

@Diederik: the column name was just an example. I want to catch any DB error, for instance it could be losing the connexion, the table being dropped etc

@joespostiga: I've tried using the try/catch to get the exception ... but it the exception is not caught (probably none are thrown).

A few more details :
The model
PHP Code:
class P_model extends CI_Model{
    
// Insert a new row in table 
    
function insert($pRow) {
        return 
$this->db->insert'P'$pRow);
    } 

Extract of the controler :
PHP Code:
            if (($handle fopen('./Files/P.csv''r')) !== FALSE) {
                
fread($handle3); // Discard the BOM
                
$header fgetcsv($handle0$mySep); // First line is headers
                
$i=0;
                try {
                    while ( ((
$data fgetcsv($handle0$mySep)) !== FALSE) OR $myDBerror) {
                        
$myDBerror= ! $this->P_model->insert(array_combine($header$data));
                        
$this->firephp->log('myDBerror et i'$myDBerror$i);
                        ++
$i;
                    }
                } catch  (
Exception $e) {
                    echo 
'Received exception : ',  $e->getMessage(), "\n";
                } 

Note that neither the $myDBerror nor the try/catch trap the error !
As a matter of fact, the debug log ($this->firephp->log) is not run when an error is generated (hence $myDBerror is completely useless).

Any ideas ?


Cheers,
L@u
Reply


Messages In This Thread
Catch DB error - by ComputingFroggy - 01-21-2016, 06:15 PM
RE: Catch DB error - by Diederik - 01-22-2016, 01:33 AM
RE: Catch DB error - by josepostiga - 01-22-2016, 02:40 AM
RE: Catch DB error - by ComputingFroggy - 01-22-2016, 05:40 AM
RE: Catch DB error - by josepostiga - 01-22-2016, 05:49 AM
RE: Catch DB error - by ComputingFroggy - 01-22-2016, 06:41 AM
RE: Catch DB error - by ComputingFroggy - 01-22-2016, 08:18 AM
RE: Catch DB error - by Shawn - 01-27-2016, 06:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB