如何在cakephp中编写更新查询
How to write update query in cakephp
$test="test's";
$contact='1234567890';
$this->Page->updateAll(
array('Page.order' => 0,"Page.name" => "'$test'","Page.contact" => "'$contact'"),
array('Page.type' => 'PROMOTED')
);
以上查询有单引号冲突。有没有其他方法可以编写更新查询。我正在使用 cakephp 2x
注意:如果您希望它们被识别为字符串字符,则在 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')
);
$test="test's";
$contact='1234567890';
$this->Page->updateAll(
array('Page.order' => 0,"Page.name" => "'$test'","Page.contact" => "'$contact'"),
array('Page.type' => 'PROMOTED')
);
以上查询有单引号冲突。有没有其他方法可以编写更新查询。我正在使用 cakephp 2x
注意:如果您希望它们被识别为字符串字符,则在 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')
);