How can I update a single field without knowing the record’s ID? I have the user’s username and I don’t want to waste resources by doing a query just to get the id.
Note: I know I can achieve this with updateAll() but that seams like over kill, but is there a better way?
Can I some how limit updateAll() to only search for one record and then finish, because I don’t want it to continue to search when there is only one possible match.
updateAll()is the way to go in this case.All the other save methods require the ID to be known.
You could also use the
query()method :$this->Model->query($sql)However, remember that values are not automatically escaped in this method.