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 "''"; return "''";
} }
if (ini_get('magic_quotes_gpc') == 1) {
$data = stripslashes($data);
}
return $this->_adodb->qstr($data); return $this->_adodb->qstr($data);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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