mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Revert "Removed the value method from MSSQL. It is provided by DboDatasource now."
This reverts commit bf0fb8302385d384239939df2ea6bc6f1a8dbaa0.
This commit is contained in:
parent
b91f6eb991
commit
24bf56b44e
1 changed files with 43 additions and 0 deletions
|
@ -221,6 +221,49 @@ class Mssql extends DboSource {
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||||
|
*
|
||||||
|
* @param string $data String to be prepared for use in an SQL statement
|
||||||
|
* @param string $column The column into which this data will be inserted
|
||||||
|
* @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
|
||||||
|
* @return string Quoted and escaped data
|
||||||
|
*/
|
||||||
|
function value($data, $column = null, $safe = false) {
|
||||||
|
$parent = parent::value($data, $column, $safe);
|
||||||
|
|
||||||
|
if ($parent != null) {
|
||||||
|
return $parent;
|
||||||
|
}
|
||||||
|
if ($data === null) {
|
||||||
|
return 'NULL';
|
||||||
|
}
|
||||||
|
if (in_array($column, array('integer', 'float', 'binary')) && $data === '') {
|
||||||
|
return 'NULL';
|
||||||
|
}
|
||||||
|
if ($data === '') {
|
||||||
|
return "''";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($column) {
|
||||||
|
case 'boolean':
|
||||||
|
$data = $this->boolean((bool)$data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (get_magic_quotes_gpc()) {
|
||||||
|
$data = stripslashes(str_replace("'", "''", $data));
|
||||||
|
} else {
|
||||||
|
$data = str_replace("'", "''", $data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($column, array('integer', 'float', 'binary')) && is_numeric($data)) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
return "'" . $data . "'";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the fields list of an SQL query.
|
* Generates the fields list of an SQL query.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue