Changeset 2193

Show
Ignore:
Timestamp:
02/28/2008 09:47:34 PM (9 months ago)
Author:
zombor
Message:

Adding support for configurable database value escaping

Location:
trunk/system/libraries/drivers
Files:
6 modified

Legend:

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

    r2064 r2193  
    278278        public function escape($value) 
    279279        { 
     280                if (!$this->db_config['escape']) 
     281                        return $value; 
     282 
    280283                switch (gettype($value)) 
    281284                { 
  • trunk/system/libraries/drivers/Database/Mssql.php

    r2190 r2193  
    124124        public function escape_column($column) 
    125125        { 
     126                if (!$this->config['escape']) 
     127                        return $column; 
     128 
    126129                if (strtolower($column) == 'count(*)' OR $column == '*') 
    127130                        return $column; 
     
    260263        public function escape_str($str) 
    261264        { 
     265                if (!$this->config['escape']) 
     266                        return $str; 
     267 
    262268                is_resource($this->link) or $this->connect(); 
    263269                //mssql_real_escape_string($str, $this->link); <-- this function doesn't exist 
  • trunk/system/libraries/drivers/Database/Mysql.php

    r2016 r2193  
    102102        public function escape_table($table) 
    103103        { 
     104                if (!$this->db_config['escape']) 
     105                        return $table; 
     106 
    104107                if (stripos($table, ' AS ') !== FALSE) 
    105108                { 
     
    118121        public function escape_column($column) 
    119122        { 
     123                if (!$this->db_config['escape']) 
     124                        return $column; 
     125 
    120126                if (strtolower($column) == 'count(*)' OR $column == '*') 
    121127                        return $column; 
     
    247253        public function escape_str($str) 
    248254        { 
     255                if (!$this->config['escape']) 
     256                        return $str; 
     257 
    249258                is_resource($this->link) or $this->connect(); 
    250259 
  • trunk/system/libraries/drivers/Database/Mysqli.php

    r2171 r2193  
    100100        public function escape_str($str) 
    101101        { 
     102                if (!$this->db_config['escape']) 
     103                        return $str; 
     104 
    102105                is_object($this->link) or $this->connect(); 
    103106 
  • trunk/system/libraries/drivers/Database/Pdosqlite.php

    r2164 r2193  
    8282        public function escape_table($table) 
    8383        { 
     84                if (!$this->config['escape']) 
     85                        return $table; 
     86 
    8487                return '`'.str_replace('.', '`.`', $table).'`'; 
    8588        } 
     
    8790        public function escape_column($column) 
    8891        { 
     92                if (!$this->config['escape']) 
     93                        return $column; 
     94 
    8995                if (strtolower($column) == 'count(*)' OR $column == '*') 
    9096                        return $column; 
     
    203209        public function escape_str($str) 
    204210        { 
     211                if (!$this->config['escape']) 
     212                        return $str; 
     213 
    205214                if(function_exists('sqlite_escape_string')) 
    206215                { 
  • trunk/system/libraries/drivers/Database/Pgsql.php

    r2185 r2193  
    8888        public function escape_table($table) 
    8989        { 
     90                if (!$this->config['escape']) 
     91                        return $table; 
     92 
    9093                return '"'.str_replace('.', '"."', $table).'"'; 
    9194        } 
     
    9396        public function escape_column($column) 
    9497        { 
     98                if (!$this->config['escape']) 
     99                        return $column; 
     100 
    95101                if (strtolower($column) == 'count(*)' OR $column == '*') 
    96102                        return $column; 
     
    214220        public function escape_str($str) 
    215221        { 
     222                if (!$this->config['escape']) 
     223                        return $str; 
     224 
    216225                is_resource($this->link) or $this->connect(); 
    217226