The central way to access and perform CRUD on users.
| User_model | The central way to access and perform CRUD on users. |
| Functions | |
| insert() | Creates a new user in the database. |
| update() | |
| find() | Finds an individual user record. |
| find_all() | Returns all user records, and their associated role information. |
| find_by() | Locates a single user based on a field/value match, with their role information. |
| count_by_roles() | Returns the number of users that belong to each role. |
| count_all() | Counts all users in the system. |
| delete() | Performs a standard delete, but also allows for purging of a record. |
| hash_password() | Generates a new salt and password hash for the given password. |
| get_login_attempts() | Returns the most recent login attempts and their description. |
public function insert( $data = array() )
Creates a new user in the database.
If no role id is passed in the $data array, it will assign the default role from Roles model.
| $data | An array of user information. |
| $id | The ID of the new user. |
public function update( $id = null, $data = array() )
| $id | An INT with the user’s ID. |
| $data | An array of key/value pairs to update for the user. |
true/false
public function find_all( $show_deleted = false )
Returns all user records, and their associated role information.
| $show_deleted | If false, will only return non-deleted users. If true, will return both deleted and non-deleted users. |
An array of objects with each user’s information.
public function find_by( $field = null, $value = null )
Locates a single user based on a field/value match, with their role information. If the $field string is ‘both’, then it will attempt to find the user where their $value field matches either the username or email on record.
| $field | A string with the field to match. |
| $value | A string with the value to search for. |
An object with the user’s info, or false on failure.
Creates a new user in the database.
public function insert( $data = array() )
public function update( $id = null, $data = array() )
Finds an individual user record.
public function find( $id = null )
Returns all user records, and their associated role information.
public function find_all( $show_deleted = false )
Locates a single user based on a field/value match, with their role information.
public function find_by( $field = null, $value = null )
Returns the number of users that belong to each role.
public function count_by_roles()
Counts all users in the system.
public function count_all( $get_deleted = false )
Performs a standard delete, but also allows for purging of a record.
public function delete( $id = 0, $purge = false )
Generates a new salt and password hash for the given password.
public function hash_password( $old = '' )
Returns the most recent login attempts and their description.
public function get_login_attempts( $limit = 15 )