-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Objects mapping: UPDATE not saved! #900
Comments
the same happens to me with php 7.3. I have had to use the update method of MysqliDb. |
the same happens to me with php 7.1. I have had to use the update method of MysqliDb. |
null value are not mantained by the class |
Its explained in the readme. You need to use db->null() to insert null
values
…On Thu, Jul 22, 2021, 5:29 PM enrybi ***@***.***> wrote:
null value are not mantained by the class
You can add my mods:
#954 <#954>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#900 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZCL4XZVSP5P3ZAF64S63LTZATOHANCNFSM4ML2R2IA>
.
|
Here? https://github.com/ThingEngineer/PHP-MySQLi-Database-Class/blob/master/readme.md#insert-data |
Hi
Because as @Padandish noted, the first instruction of update() is to test $this->dbFields which is not defined as a class variable and is not initialized anywhere. The function save() can't work for an update I started a development using this library because it looked simple.But if a function as basic as update doesn't work, I'll have to find something else. |
The example code as it stands does not work. This needs clarifying properly in the documentation, or dbFields should be made optional. $dbFields needs to be created and set to an array of your database field names. The documentation mentions this in passing but it is easily missed, as it is not shown in the example code.
It appears you do not need to set the validation rules in dbFields as suggested in the documentation - as far as I can tell, you can just set it to a flat array of field names. I might be wrong on that; I haven't tested thoroughly yet. You can define dbFields in your class extending dbObject.
There doesn't seem to be a way of doing this if you've defined your class using |
Hi dear,
Thanks for nice Library.
I used Object mapping. after run code:
$user = user::byId(1);
$user->password = 'demo2';
$user->save();
But not saved!, I traced code, and problem at dbObject.php
public function update ($data = null) {
if (empty ($this->dbFields))
return false;
...}
$this->dbFields is empty and not defined.
"thingengineer/mysqli-database-class": "v2.9.3"
PHP 7.4.4
Thanks
The text was updated successfully, but these errors were encountered: