Changeset 2226

Show
Ignore:
Timestamp:
03/06/2008 12:02:41 PM (10 months ago)
Author:
zombor
Message:

Fixing #463. Thanks ixmatus!

Files:
1 modified

Legend:

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

    r2208 r2226  
    236236                is_resource($this->link) or $this->connect(); 
    237237                //mssql_real_escape_string($str, $this->link); <-- this function doesn't exist 
    238                  
    239                 /* Below is my test of the addcslashes function to mimic the mysql_real_escape_string function 
    240                  *  
    241                  * $array       = array('\x00', '\x1a', '\n', '\r', '\\', "'", '"'); 
    242                  * foreach($array as $item) 
    243                  * { 
    244                  *        echo addcslashes($item, '\\\'"').'<br />'; 
    245                  * } 
    246                  */ 
    247                 $characters     = array('/\x00/', '/\x1a/', '/\n/', '/\r/', '/\\\/', '/\'/', '/\"/'); 
    248                 return preg_replace($characters, '\\', $str); 
     238 
     239                $characters = array('/\x00/', '/\x1a/', '/\n/', '/\r/', '/\\\/', '/\'/'); 
     240                $replace    = array('\\\x00', '\\x1a', '\\n', '\\r', '\\\\', "''"); 
     241                return preg_replace($characters, $replace, $str); 
    249242        } 
    250243