Welcome Guest, Not a member yet? Register   Sign In
You must use the "set" method to update an entry
#1

Hi there!

I'm evolving from CI3 to CI4 but recently i had a problem that couldn't be resolved Googling or Searching into this forums so, i decided to create this topic:

The Question:

I'm trying to update a record's password but i couldn't do it with those three methods:

Code:
$DATA = [
                    'u_id' => $_SESSION['u_id'],
                    'u_secret' => password_hash($this->request->getPost('newpass'), PASSWORD_DEFAULT)
                ];
                $usuario->save($DATA);
Code:
$DATA = [                    
                    'u_secret' => password_hash($this->request->getPost('newpass'), PASSWORD_DEFAULT)
                ];                
                $usuario->update($_SESSION['u_id'], $DATA);

Code:
$DATA = [
                    'u_secret' => password_hash($this->request->getPost('newpass'), PASSWORD_DEFAULT)
                ];
                $usuario->set($DATA);
                $usuario->where('u_id', $_SESSION['u_id']);
                $usuario->update();

Code:
$usuario->set('u_secret', password_hash($this->request->getPost('newpass'), PASSWORD_DEFAULT));
                $usuario->where('u_id', $_SESSION['u_id']);
                $usuario->update();

In all these tests, the resultant 500 Error is this:

Quote:Uncaught Error: { "title": "CodeIgniter\\Database\\Exceptions\\DatabaseException", "type": "CodeIgniter\\Database\\Exceptions\\DatabaseException", "code": 500, "message": "You must use the \"set\" method to update an entry.", "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/Database/BaseBuilder.php", "line": 2517, "trace": [ { "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/Database/BaseBuilder.php", "line": 2430, "function": "validateUpdate", "class": "CodeIgniter\\Database\\BaseBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/Model.php", "line": 889, "function": "update", "class": "CodeIgniter\\Database\\BaseBuilder", "type": "->", "args": [] }, { "file": "/var/www/html/economato/app/Controllers/Usuario.php", "line": 51, "function": "update", "class": "CodeIgniter\\Model", "type": "->", "args": [] }, { "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/CodeIgniter.php", "line": 918, "function": "commitpwdchange", "class": "App\\Controllers\\Usuario", "type": "->", "args": [] }, { "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/CodeIgniter.php", "line": 404, "function": "runController", "class": "CodeIgniter\\CodeIgniter", "type": "->", "args": [ { "session": {} } ] }, { "file": "/var/www/html/economato/vendor/codeigniter4/framework/system/CodeIgniter.php", "line": 312, "function": "handleRequest", "class": "CodeIgniter\\CodeIgniter", "type": "->", "args": [ null, { "handler": "file", "backupHandler": "dummy", "storePath": "/var/www/html/economato/writable/cache/", "cacheQueryString": false, "prefix": "", "memcached": { "host": "127.0.0.1", "port": 11211, "weight": 1, "raw": false }, "redis": { "host": "127.0.0.1", "password": null, "port": 6379, "timeout": 0, "database": 0 }, "validHandlers": { "dummy": "CodeIgniter\\Cache\\Handlers\\DummyHandler", "file": "CodeIgniter\\Cache\\Handlers\\FileHandler", "memcached": "CodeIgniter\\Cache\\Handlers\\MemcachedHandler", "predis": "CodeIgniter\\Cache\\Handlers\\PredisHandler", "redis": "CodeIgniter\\Cache\\Handlers\\RedisHandler", "wincache": "CodeIgniter\\Cache\\Handlers\\WincacheHandler" } }, false ] }, { "file": "/var/www/html/economato/index.php", "line": 45, "function": "run", "class": "CodeIgniter\\CodeIgniter", "type": "->", "args": [] } ] }


I know it cames with data but isn't so relevant for privacy.

But i can't update the record trying 4 methods. ¿Is something wrong with the settings?
Please let me know.

Thanks for eventual response.  Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB