-
Notifications
You must be signed in to change notification settings - Fork 360
save() fails silently if you have select()ed some fields, but not the id #203
Copy link
Copy link
Closed
Description
Given the following table
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(254) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;With the data
INSERT INTO `users` (`id`, `email`)
VALUES ('1', '[email protected]');And the following code
$user = ORM::for_table('users')
->where('id', 1)
->select('email')
->find_one()
;
$user->email = '[email protected]';
$success = $user->save();$success is true, but the database will not have reflected this change (email will still be [email protected]).
get_last_query() indicates that the following query is being executed
UPDATE `users` SET `email` = '[email protected]' WHERE `id` = ''Notice that it could not find the id value to place in the query.
A work around is to remove the select() call altogether, or at least call select('id'), but I still think this is a bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels