-
Notifications
You must be signed in to change notification settings - Fork 194
Model Users
SuperScript edited this page Aug 16, 2014
·
4 revisions
Model | Extends | Table | Path |
---|---|---|---|
Users_Model | Plain_Model | users | /application/models/users_model.php |
$this->load->model('users_model', 'users');
Property | Visibility | Default Value | Description |
---|---|---|---|
$sort | Public | user_id DESC | The default sort direction for reads. |
Called automatically which in turn calls the parent constructor and sets the model $data_types
properties.
Used to create new records in the users table.
Variable | Type | Default | Required | Description |
---|---|---|---|---|
$options | array | array() | Yes | An associative array that contains the column names and the values for the record to be created. Array keys are the column names for each value. |
$options['email'] | string | N/A | Yes | The email address for the user. |
$options['password'] | string | N/A | Yes | The password for the user. The method will encrypt it for you. |
$this->load->model('users_model', 'users');
$user = $this->users->create(array('email' => $name, 'password' => $password));
// If user was created
if (isset($user->user_id)) {
// Good to go
}
// Some sort of validation error
elseif (isset($user['errors']) {
// Validation errors were found
}
// Some sort of database write error, check logs
else {
// will return false
}