Changeset 24

Show
Ignore:
Timestamp:
05/15/07 22:24:00
Author:
svn
Message:

only show errors if debug enabled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phptagengine.class.inc.php

    r23 r24  
    176176         */ 
    177177        var $version; 
     178        /** 
     179         * Show or hide error messages 
     180         * 
     181         * @var boolean 
     182         */ 
     183        var $debug; 
    178184         
    179185        /** 
     
    200206                ); 
    201207                $this->version = '1.01'; 
     208                $this->debug = false; 
    202209        } 
    203210         
     
    292299                        ( ".$this->db->qstr($tag)."                      
    293300                        ) 
    294                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     301                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    295302                 
    296303                if ($result) { 
     
    299306                                $id = $this->db->GetOne(" 
    300307                                        SELECT CURRVAL('".$this->table_tag_names."_id_seq') as id 
    301                                 ") or die($this->db->ErrorMsg()); 
     308                                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    302309                        } 
    303310                        else { 
     
    353360                                , ".$this->db->DBDate(date("Y-m-d H:i:s"))." 
    354361                                ) 
    355                         ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     362                        ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    356363                        if ($result) { 
    357364                                return true; 
     
    446453                        FROM $this->table_tags 
    447454                        WHERE id = ".$this->db->qstr($id)." 
    448                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     455                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    449456                if ($result) { 
    450457                        return true; 
     
    495502                        $where 
    496503                        ORDER BY tn.name 
    497                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     504                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    498505                if ($result && $result->RowCount() > 0) { 
    499506                        while ($data = $result->FetchNextObject()) { 
     
    522529                        FROM $this->table_tags 
    523530                        WHERE tag = '$tag_id' 
    524                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     531                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    525532                if (!$result) { 
    526533                        return false; 
     
    530537                        FROM $this->table_tag_names 
    531538                        WHERE id = '$tag_id' 
    532                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     539                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    533540                if (!$result) { 
    534541                        return false; 
     
    559566                                SET tag = '$new_tag_id' 
    560567                                WHERE tag = '$old_tag_id' 
    561                         ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     568                        ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    562569                        if (!$result) { 
    563570                                return false; 
     
    568575                                FROM $this->table_tags 
    569576                                WHERE tag = '$new_tag_id' 
    570                         ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     577                        ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    571578                        if (!$result) { 
    572579                                return false; 
     
    590597                                                FROM $this->table_tags 
    591598                                                WHERE id IN (".implode(',', $ids_to_delete).") 
    592                                         ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     599                                        ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    593600                                        if (!$result) { 
    594601                                                return false; 
     
    602609                                SET name = ".$this->db->qstr($new_tag)." 
    603610                                WHERE name = ".$this->db->qstr($old_tag)." 
    604                         ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     611                        ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    605612                        if (!$result) { 
    606613                                return false; 
     
    648655                        $where 
    649656                        ORDER BY t.item, tn.name 
    650                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     657                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    651658                if ($result) { 
    652659                        while ($data = $result->FetchNextObject()) { 
     
    674681                        FROM $this->table_tag_names 
    675682                        WHERE name = ".$this->db->qstr($name)." 
    676                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     683                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    677684                if ($result && $result->RowCount() == 1) { 
    678685                        while ($data = $result->FetchNextObject()) { 
     
    812819                        ON tn.id = t.tag 
    813820                        ORDER BY tn.name 
    814                 ") or die($this->db->ErrorMsg().' in '.__FILE__); 
     821                ") or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    815822                if ($result) { 
    816823                        while ($data = $result->FetchNextObject()) { 
     
    11861193                                        ,$data 
    11871194                                ) 
    1188                         ) or die($this->db->ErrorMsg().' on '.__LINE__.' in '.__FILE__); 
     1195                        ) or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    11891196                         
    11901197                        if ($result) { 
     
    12031210                                                                ,$extra 
    12041211                                                        ) 
    1205                                                 ) or die($this->db->ErrorMsg().' on '.__LINE__.' in '.__FILE__); 
     1212                                                ) or die(throw_error($this->db->ErrorMsg(), __FILE__, __LINE__)); 
    12061213                                                if (!$result) { 
    12071214                                                        $error++; 
     
    12211228                } 
    12221229        } 
     1230         
     1231        /** 
     1232         * Print error, or not, depending on debug setting. 
     1233         * 
     1234         * @return string 
     1235         */ 
     1236        function throw_error($msg, $file, $line) { 
     1237                if ($this->debug) { 
     1238                        return $msg.' in '.$file.' on line: '.$line; 
     1239                } 
     1240        } 
    12231241} 
    12241242