2012/12/13 polutan <linspirell@gmail.com>
I get SQL error when doing Model::updateAll() . The error appeared because my data string not quoted with single quote. It seems cake is not automatically single quoting my data.
This is the screenshoot. Please check this out :
http://img546.imageshack.us/img546/2289/localhosttaskmonusersed.png
This is my code :
$data = array(
"User.username" => "'".$this->request->data["User"]["username"]."'", // I Manually single quoting the data
"User.group_id" => $this->request->data["User"]["group_id"],
"User.modified" => date("Y-m-d H:i:s") // the error come from here
);
$conds = array(
"User.id" => (int) $this->request->data["User"]["id"]
);
if (!empty($this->request->data["User"]["password"])) {
$data["User.password"] = "'".AuthComponent::password($this->request->data["User"]["password"])."'"; // I Manually single quoting the data
}
if ($this->User->updateAll($data,$conds)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
Thank you
--
Coklat Stroberi -- Web Dev Training Centre
http://www.facebook.com/pages/Coklat-Stroberi/249514251728226 (info lebih lanjut)
Jl. Raya Padang Luwih (Dalung) No.141 - Telp. (0361) 9006118 atau 08174128301 - Badung, Bali. Sebelah timur traffic light pertigaan perumahan dalung permai.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment