$test="test's";
$contact='1234567890';
$this->Page->updateAll(
array('Page.order' => 0,"Page.name" => "'$test'","Page.contact" => "'$contact'"),
array('Page.type' => 'PROMOTED')
);
以上查询有单引号冲突。有没有其他方法来编写更新查询。我正在使用cakephp 2x
答案 0 :(得分:0)
注意:如果要将它们识别为字符串变量字符,则必须在php中反斜杠具有其他含义的字符。例如(测试需要测试
)尝试:
$db = $this->getDataSource();
$test = $db->value('test\'s');
$contact = $db->value('1234567890');
$this->Page->updateAll(
array('Page.order' => 0,"Page.name" => $test,"Page.contact" => $contact),
array('Page.type' => 'PROMOTED')
);