Class Admins_Model
Admins_Model Class
Handles the database actions for admin users management.
Data Structure: 'fist_name' 'last_name' (required) 'email' (required)
'mobile_number' 'phone_number' (required) 'address' 'city' 'state' 'zip_code'
'notes' 'id_roles' 'settings' >>> array that contains user settings
(username, password etc)
-
CI_Model
-
Admins_Model
Methods summary
public
|
|
public
integer
|
#
add( array $admin )
Add (insert or update) an admin user record into database.
Add (insert or update) an admin user record into database.
Parameters
- $admin
array $admin Contains the admin user data.
Returns
integer Returns the record id.
Throws
Exception
When the admin data are invalid (see validate() method).
|
public
boolean
|
#
exists( array $admin )
Check whether a particular admin record exists in the database.
Check whether a particular admin record exists in the database.
Parameters
- $admin
array $admin Contains the admin data. The 'email' value is required to be present at
the moment.
Returns
boolean Returns whether the record exists or not.
Throws
Exception
When the 'email' value is not present on the $admin argument.
|
public
integer
|
#
insert( array $admin )
Insert a new admin record into the database.
Insert a new admin record into the database.
Parameters
- $admin
array $admin Contains the admin data.
Returns
integer Returns the new record id.
Throws
|
public
integer
|
#
update( array $admin )
Update an existing admin record in the database.
Update an existing admin record in the database.
Parameters
- $admin
array $admin Contains the admin record data.
Returns
integer Retuns the record id.
Throws
|
public
integer
|
#
find_record_id( array $admin )
Find the database record id of an admin user.
Find the database record id of an admin user.
Parameters
- $admin
array $admin Contains the admin data. The 'email' value is required in order to find
the record id.
Returns
integer Returns the record id
Throws
Exception
When the 'email' value is not present on the $admin array.
|
public
boolean
|
#
validate( array $admin )
Validate admin user data before add() operation is executed.
Validate admin user data before add() operation is executed.
Parameters
- $admin
array $admin Contains the admin user data.
Returns
boolean Returns the validation result.
|
public
boolean
|
#
delete( numeric $admin_id )
Delete an existing admin record from the database.
Delete an existing admin record from the database.
Parameters
- $admin_id
numeric $admin_id The admin record id to be deleted.
Returns
boolean Returns the delete operation result.
Throws
Exception
When the $admin_id is not a valid numeric value.
Exception
When the record to be deleted is the only one admin user left on the system.
|
public
array
|
#
get_row( numeric $admin_id )
Get a specific admin record from the database.
Get a specific admin record from the database.
Parameters
- $admin_id
numeric $admin_id The id of the record to be returned.
Returns
array Returns an array with the admin user data.
Throws
Exception
When the $admin_id is not a valid numeric value.
|
public
string
|
#
get_value( string $field_name, numeric $admin_id )
Get a specific field value from the database.
Get a specific field value from the database.
Parameters
- $field_name
string $field_name The field name of the value to be returned.
- $admin_id
numeric $admin_id Record id of the value to be returned.
Returns
string Returns the selected record value from the database.
Throws
Exception
When the $field_name argument is not a valid string.
Exception
When the $admin_id is not a valid numeric.
Exception
When the admin record does not exist in the database.
Exception
When the selected field value is not present on database.
|
public
array
|
#
get_batch( string|array $where_clause = '' )
Get all, or specific admin records from database.
Get all, or specific admin records from database.
Parameters
- $where_clause
string|array $where_clause (OPTIONAL) The WHERE clause of the query to be executed. Use this
to get specific admin records.
Returns
array Returns an array with admin records.
|
public
integer
|
#
get_admin_role_id( )
Get the admin users role id.
Get the admin users role id.
Returns
integer Returns the role record id.
|