Issue
$test="test's";
$contact='1234567890';
$this->Page->updateAll(
array('Page.order' => 0,"Page.name" => "'$test'","Page.contact" => "'$contact'"),
array('Page.type' => 'PROMOTED')
);
Above query having single quote conflict. Is there any other way to write update query . I am using cakephp 2x
Solution
NOTE: Must backslash characters that have another meaning in php if you want them to be recognized as string caharacters. e.g(test's needs be test\'s)
try:
$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')
);
Answered By - Jason Joslin Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.