Adding fix for #1396.

Would not allow saving values with \ in the string

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3504 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-09-16 02:39:06 +00:00
parent 2e581426be
commit ead9f329e9
8 changed files with 29 additions and 57 deletions

View file

@ -319,10 +319,6 @@ class DboAdodb extends DboSource{
return "''";
}
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
return $this->_adodb->qstr($data);
}

View file

@ -267,9 +267,6 @@ class DboMssql extends DboSource {
$data = $this->boolean((bool)$data);
break;
default:
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
$data = addslashes($data);
break;
}

View file

@ -235,9 +235,6 @@ class DboMysql extends DboSource {
$data = $this->boolean((bool)$data);
break;
default:
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
$data = mysql_real_escape_string($data, $this->connection);
break;
}

View file

@ -103,8 +103,8 @@ class DboMysqli extends DboSource {
if (mysqli_select_db($this->connection, $config['database'])) {
$this->connected = true;
}
}
return $this->connected;
}
/**
@ -123,19 +123,19 @@ class DboMysqli extends DboSource {
* @return resource Result resource identifier
* @access protected
*/
function _execute($sql) {
return mysqli_query($this->connection, $sql);
function _execute($sql) {
return mysqli_query($this->connection, $sql);
}
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources() {
function listSources() {
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
}
$result = $this->_execute('SHOW TABLES FROM ' . $this->config['database'] . ';');
if (!$result) {
return array();
@ -145,7 +145,7 @@ class DboMysqli extends DboSource {
while ($line = mysqli_fetch_array($result)) {
$tables[] = $line[0];
}
parent::listSources($tables);
return $tables;
}
@ -156,16 +156,16 @@ class DboMysqli extends DboSource {
* @param string $tableName Name of database table to inspect
* @return array Fields in table. Keys are name and type
*/
function describe(&$model) {
function describe(&$model) {
$cache = parent::describe($model);
if ($cache != null) {
return $cache;
}
$fields = false;
$cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
$cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
foreach ($cols as $column) {
$colKey = array_keys($column);
if (isset($column[$colKey[0]]) && !isset($column[0])) {
@ -179,8 +179,8 @@ class DboMysqli extends DboSource {
'default' => $column[0]['Default']
);
}
}
}
$this->__cacheDescription($model->tablePrefix.$model->table, $fields);
return $fields;
}
@ -228,9 +228,6 @@ class DboMysqli extends DboSource {
$data = $this->boolean((bool)$data);
break;
default:
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
$data = mysqli_real_escape_string($this->connection, $data);
break;
}
@ -388,36 +385,36 @@ class DboMysqli extends DboSource {
*
* @param unknown_type $results
*/
function resultSet(&$results) {
function resultSet(&$results) {
$this->results =& $results;
$this->map = array();
$num_fields = mysqli_num_fields($results);
$num_fields = mysqli_num_fields($results);
$index = 0;
$j = 0;
while ($j < $num_fields) {
$column = mysqli_fetch_field_direct($results, $j);
$column = mysqli_fetch_field_direct($results, $j);
if (!empty($column->table)) {
$this->map[$index++] = array($column->table, $column->name);
} else {
} else {
$this->map[$index++] = array(0, $column->name);
}
$j++;
}
}
}
/**
* Fetches the next row from the current result set
*
* @return unknown
*/
function fetchResult() {
if ($row = mysqli_fetch_row($this->results)) {
function fetchResult() {
if ($row = mysqli_fetch_row($this->results)) {
$resultRow = array();
$i = 0;
foreach ($row as $index => $field) {
@list($table, $column) = $this->map[$index];
$resultRow[$table][$column] = $row[$index];
$i++;
}
$i = 0;
foreach ($row as $index => $field) {
@list($table, $column) = $this->map[$index];
$resultRow[$table][$column] = $row[$index];
$i++;
}
return $resultRow;
} else {
return false;
@ -428,8 +425,8 @@ class DboMysqli extends DboSource {
*
* @param bool $assoc Associative array only, or both?
* @return array The fetched row as an array
*/
function fetchRow($assoc = false) {
*/
function fetchRow($assoc = false) {
if (is_object($this->_result)) {
$this->resultSet($this->_result);
$resultRow = $this->fetchResult();

View file

@ -236,9 +236,6 @@ class DboOdbc extends DboSource{
return 'NULL';
}
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
// $data = mysql_real_escape_string($data, $this->connection);
if (!is_numeric($data)) {

View file

@ -245,9 +245,6 @@ class DboPostgres extends DboSource{
break;
default:
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
$data = pg_escape_string($data);
break;
}

View file

@ -218,10 +218,6 @@ class DboSqlite extends DboSource {
$data = $this->boolean((bool)$data);
break;
default:
if (ini_get('magic_quotes_gpc') == 1)
{
$data = stripslashes($data);
}
$data = sqlite_escape_string($data);
break;
}

View file

@ -223,12 +223,7 @@ class DboSybase extends DboSource {
$data = $this->boolean((bool)$data);
break;
default:
if (get_magic_quotes_gpc() && trim(ini_get("magic_quotes_sybase")) == "") {
$data = stripslashes($data);
$data = str_replace("'", "''", $data);
} elseif (!get_magic_quotes_gpc()) {
$data = str_replace("'", "''", $data);
}
$data = str_replace("'", "''", $data);
break;
}