Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669444yWhen your passing an array of column name / value pairs you need to use set() before calling where / update.
Don't worry, I dislike CI aswell 😅
@highlight
$data = array(
'name' => 'test',
'email' => 'test@example.com'
);
$this->db->set($data)
$this->db->where('id', $id);
$this->db->update('users'); -
C0D4669444y@nine what's in $data, and do the array keys match the db column names?
Got a gist with more code I can look at? -
C0D4669444y@nine odd, that should work.
Which version of CI are you using?
Yanking out the old code base here, you should be able to do this:
do you hand it an id, or is the Id inside $data?
@highlight
$id = 1;
$data = array("name" => "test");
$this->db->where("id", $id);
$this->db->update("tableName", $data);
// which would produce:
# update tableName set name = "test" where id = 1;
// alternatively
$this->db->update("tableName", $data, "id = 1");
Related Rants
So this is the scenario:
A Database Error Occurred: You must use the “set” method to update an entry
This is the code:
$this->db->where('id', $id);
return $this->db->update('contractors', ((array) $contractor));
And it gives me the error A Database Error Occurred: You must use the "set" method to update an entry.
question
server
api
code ignitor
database
php