Show
Ignore:
Timestamp:
02/25/2008 09:37:34 AM (11 months ago)
Author:
zombor
Message:

Fixing #422.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/drivers/Database/Pgsql.php

    r2162 r2165  
    351351                if (is_resource($result)) 
    352352                { 
    353                         $this->current_row = 0; 
    354                         $this->total_rows  = pg_num_rows($this->result); 
    355                         $this->fetch_type = ($object === TRUE) ? 'pg_fetch_object' : 'pg_fetch_array'; 
    356                 } 
    357                 elseif (is_bool($result)) 
    358                 { 
    359                         if ($result == FALSE) 
    360                         { 
    361                                 // SQL error 
    362                                 throw new Kohana_Database_Exception('database.error', pg_last_error().' - '.$sql); 
     353                        // Its an DELETE, INSERT, REPLACE, or UPDATE query 
     354                        if (preg_match('/^(?:delete|insert|replace|update)\s+/i', trim($sql), $matches)) 
     355                        { 
     356                                $this->insert_id  = (strtolower($matches[0]) == 'insert') ? $this->get_insert_id($link) : FALSE; 
     357                                $this->total_rows = pg_affected_rows($link); 
    363358                        } 
    364359                        else 
    365360                        { 
    366                                 // Its an DELETE, INSERT, REPLACE, or UPDATE query 
    367                                 $this->insert_id  = $this->get_insert_id($link); 
    368                                 $this->total_rows = pg_affected_rows($link); 
    369                         } 
    370                 } 
     361                                $this->current_row = 0; 
     362                                $this->total_rows  = pg_num_rows($this->result); 
     363                                $this->fetch_type = ($object === TRUE) ? 'pg_fetch_object' : 'pg_fetch_array'; 
     364                        } 
     365                } 
     366                else 
     367                        throw new Kohana_Database_Exception('database.error', pg_last_error().' - '.$sql); 
    371368 
    372369                // Set result type