mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding support for Unicode characters. Refs #1321
This commit is contained in:
parent
623466dcf8
commit
9ab2ec7d49
2 changed files with 30 additions and 6 deletions
|
@ -548,6 +548,30 @@ class Sqlserver extends DboSource {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return string Quoted and escaped data
|
||||
*/
|
||||
public function value($data, $column = null) {
|
||||
if (is_array($data) || is_object($data)) {
|
||||
return parent::value($data, $column);
|
||||
}
|
||||
|
||||
if (empty($column)) {
|
||||
$column = $this->introspectType($data);
|
||||
}
|
||||
|
||||
switch ($column) {
|
||||
case 'string':
|
||||
case 'text':
|
||||
return 'N' . $this->_connection->quote($data, PDO::PARAM_STR);
|
||||
default:
|
||||
return parent::value($data, $column);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns an array of all result rows for a given SQL query.
|
||||
* Returns false if no rows matched.
|
||||
|
|
|
@ -491,7 +491,7 @@ class SqlserverTest extends CakeTestCase {
|
|||
|
||||
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255');
|
||||
$result = $this->db->buildColumn($column);
|
||||
$expected = '[name] varchar(255) DEFAULT \'\' NOT NULL';
|
||||
$expected = '[name] varchar(255) DEFAULT N\'\' NOT NULL';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
|
||||
|
@ -511,7 +511,7 @@ class SqlserverTest extends CakeTestCase {
|
|||
|
||||
$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
|
||||
$result = $this->db->buildColumn($column);
|
||||
$expected = '[name] varchar(255) DEFAULT \'\'';
|
||||
$expected = '[name] varchar(255) DEFAULT N\'\'';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
|
@ -591,8 +591,8 @@ class SqlserverTest extends CakeTestCase {
|
|||
$result = $this->db->simulated;
|
||||
$expected = array(
|
||||
'SET IDENTITY_INSERT [sqlserver_test_models] ON',
|
||||
"INSERT INTO [sqlserver_test_models] ([id], [name], [login]) VALUES (1, 'Larry', 'PhpNut')",
|
||||
"INSERT INTO [sqlserver_test_models] ([id], [name], [login]) VALUES (2, 'Renan', 'renan.saddam')",
|
||||
"INSERT INTO [sqlserver_test_models] ([id], [name], [login]) VALUES (1, N'Larry', N'PhpNut')",
|
||||
"INSERT INTO [sqlserver_test_models] ([id], [name], [login]) VALUES (2, N'Renan', N'renan.saddam')",
|
||||
'SET IDENTITY_INSERT [sqlserver_test_models] OFF'
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
@ -605,8 +605,8 @@ class SqlserverTest extends CakeTestCase {
|
|||
$this->db->insertMulti($this->model, $fields, $values);
|
||||
$result = $this->db->simulated;
|
||||
$expected = array(
|
||||
"INSERT INTO [sqlserver_test_models] ([name], [login]) VALUES ('Larry', 'PhpNut')",
|
||||
"INSERT INTO [sqlserver_test_models] ([name], [login]) VALUES ('Renan', 'renan.saddam')",
|
||||
"INSERT INTO [sqlserver_test_models] ([name], [login]) VALUES (N'Larry', N'PhpNut')",
|
||||
"INSERT INTO [sqlserver_test_models] ([name], [login]) VALUES (N'Renan', N'renan.saddam')",
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue