Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function update()
- {
- $fields = get_object_vars($this);
- $mask = [];
- $data = [];
- foreach ($fields as $name => $value){
- if($name == 'id') {
- continue;
- }
- $mask[$name . ' = :' . $name] = null;
- $data[':' . $name] = $value;
- }
- $data[':id'] = $this->id;
- $sql = 'UPDATE ' .
- static::TABLE . ' SET ' . implode(', ', array_keys($mask)) . ' WHERE id = :id';
- $db = new Db();
- $db->execute($sql, $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement