I’m trying to update table data from a database in CakePHP.
Query:
UPDATE status SET amount=5000 WHERE id=3
How to write this query in CakePHP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look at documentation and see the CakePHP way of dealing with models (and database tables).
In this case I think you could use
set()andsave():or a shorter version with
saveField():The difference between them is that
saveField()is kind of an atomic update, while multipleset()calls do not modify the data until you do asave()call.