ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.29k stars 1.35k forks source link

All objects share the same queries #938

Open geek-at opened 3 years ago

geek-at commented 3 years ago

I have a few classes extended using the described initialization method of class User extends dbObject {}

Now I'm creating a new item like so

$user = new User;

$user->firstname = $_REQUEST['firstname'];
$user->lastname = $_REQUEST['lastname'];

$user->save();

Which works perfectly but now I want to add a value that's decided by another class like

$user = new User;

$user->firstname = $_REQUEST['firstname'];
$user->lastname = $_REQUEST['lastname'];

$ip = new IpVerification;
$allowed = $ip->where('ip','127.0.0.1')->getOne()->allowed;
$user->is_admin  = $allowed;

$user->save();

The save never goes through because the "where" statement is for some reason added to the $user query too (which fails because the fields are not the same.

Is this intentionally and how can I work around it?