Skip to content

Usage of User Model

Häbu edited this page Mar 31, 2017 · 6 revisions

User-Model

Creating an instance of a user

You can create the user by offering user-properties and you should set the Database instance afterwards. For the Crud Operations it is not important to make an instance of the class, cause all CRUD-operations are defined static.

Code-Example

$user = new User([ID] = NULL,[EMAIL] = NULL,[PASSWORD] = NULL);
$user->setDatabase([DATABASE INSTANCE]);

Adding a user

User::addUser([USERNAME],[PASSWORD]);

Selecting a user

It's possible to select a whole user-entity (without password) by user-id or e-mail. Returns a user-object.

User::selectUserByName([EMAIL]);
User::selectUserById([ID]);

Deleting a user

User::deleteUser([ID]);

Updating a user

Each parameter unless the id is optional. If u don't need the first but the second or the third for example, then place empty string-containers as placeholders in the method-call

User::updateUser([ID],[USERNAME],[PASSWORD]);

Verifing a user (Login)

Returns a boolean

User::verifyUser([EMAIL],[PASSWORD_CLEAR]);