mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing substring quoting in DboSource::__quoteFields()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5274 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
335a384613
commit
3dbf59ece3
2 changed files with 5 additions and 2 deletions
|
@ -1625,10 +1625,9 @@ class DboSource extends DataSource {
|
||||||
|
|
||||||
for($i = 0; $i < $pregCount; $i++) {
|
for($i = 0; $i < $pregCount; $i++) {
|
||||||
if(!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
|
if(!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
|
||||||
$conditions = preg_replace('/\b' . $replace['0'][$i] . '\b/', $this->name($replace['1'][$i]), $conditions);
|
$conditions = preg_replace('/\b' . preg_quote($replace['1'][$i]) . '\b/', $this->name($replace['1'][$i]), $conditions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$conditions = rtrim($conditions);
|
|
||||||
return $conditions;
|
return $conditions;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1314,6 +1314,10 @@ class DboSourceTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testStringConditionsParsing() {
|
function testStringConditionsParsing() {
|
||||||
|
$result = $this->db->conditions("ProjectBid.project_id = Project.id");
|
||||||
|
$expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`";
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->db->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'");
|
$result = $this->db->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'");
|
||||||
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
|
$expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
Loading…
Add table
Reference in a new issue