mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing Sqlserver::value() as it is already abstracted in DboSource
This commit is contained in:
parent
f79fc74aad
commit
97e51f1d94
2 changed files with 2 additions and 50 deletions
|
@ -232,54 +232,6 @@ class Sqlserver extends DboSource {
|
|||
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
|
||||
*/
|
||||
public function value($data, $column = null, $safe = false) {
|
||||
$parent = parent::value($data, $column, $safe);
|
||||
|
||||
if ($column === 'float' && strpos($data, '.') !== false) {
|
||||
return rtrim($data, '0');
|
||||
}
|
||||
if ($parent === "''" && ($column === null || $column !== 'string')) {
|
||||
return 'NULL';
|
||||
}
|
||||
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.
|
||||
|
|
|
@ -277,7 +277,7 @@ class SqlserverTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testQuoting() {
|
||||
$expected = "1.2";
|
||||
$expected = "1.200000";
|
||||
$result = $this->db->value(1.2, 'float');
|
||||
$this->assertIdentical($expected, $result);
|
||||
|
||||
|
@ -293,7 +293,7 @@ class SqlserverTest extends CakeTestCase {
|
|||
$result = $this->db->value('', 'float');
|
||||
$this->assertIdentical($expected, $result);
|
||||
|
||||
$expected = 'NULL';
|
||||
$expected = "''";
|
||||
$result = $this->db->value('', 'binary');
|
||||
$this->assertIdentical($expected, $result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue