Methods summary
public
|
|
public
integer
|
#
add( array $customer_data )
Add a customer record to the database.
Add a customer record to the database.
This method adds a customer to the database. If the customer doesn't exists
it is going to be inserted, otherwise the record is going to be updated.
Parameters
- $customer_data
array $customer_data Associative array with the customer's data. Each key has the same
name with the database fields.
Returns
integer Returns the customer id.
ExpectedException
ValidationException When customer's data are invalid.
DatabaseException When update or insert method fails.
|
public
boolean
|
#
exists( array $customer_data )
Check if a particular customer record already exists.
Check if a particular customer record already exists.
This method checks wether the given customer already exists in the database.
It doesn't search with the id, but with the following fields: "email"
Parameters
- $customer_data
array $customer_data Associative array with the customer's data. Each key has the same
name with the database fields.
Returns
boolean Returns wether the record exists or not.
ExpectedException
InvalidArgumentException When the $customer_data array does not contain all the
necessary fields.
|
public
integer
|
#
find_record_id( array $customer_data )
Find the database id of a customer record.
Find the database id of a customer record.
The customer data should include the following fields in order to get the
unique id from the database: "email"
<strong>IMPORTANT!</strong> The record must already exists in the
database, otherwise an exception is raised.
Parameters
- $customer_data
array $customer_data Array with the customer data. The keys of the array should have
the same names as the db fields.
Returns
integer Returns the id.
ExpectedException
DatabaseException When the record is not found.
|
public
boolean
|
#
validate_data( array $customer_data )
Validate customer data before the insert or update operation is executed.
Validate customer data before the insert or update operation is executed.
Parameters
- $customer_data
array $customer_data Contains the customer data.
Returns
boolean Returns the validation result.
|
public
boolean
|
#
delete( integer $customer_id )
Delete an existing customer record from the database.
Delete an existing customer record from the database.
Parameters
- $customer_id
integer $customer_id The record id to be deleted.
Returns
boolean Returns the delete operation result.
ExpectedException
InvalidArgumentException Raises when the $customer_id is not an integer.
|
public
array
|
#
get_row( integer $customer_id )
Get a specific row from the appointments table.
Get a specific row from the appointments table.
Parameters
- $customer_id
integer $customer_id The record's id to be returned.
Returns
array Returns an associative array with the selected record's data. Each key has the
same name as the database field names.
|
public
string
|
#
get_value( string $field_name, integer $customer_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.
- $customer_id
integer $customer_id The selected record's id.
Returns
string Returns the records value from the database.
|
public
array
|
#
get_batch( string $where_clause = '' )
Get all, or specific records from appointment's table.
Get all, or specific records from appointment's table.
Parameters
- $where_clause
string $whereClause (OPTIONAL) The WHERE clause of the query to be executed. DO NOT
INCLUDE 'WHERE' KEYWORD.
Returns
array Returns the rows from the database.
Example
$this->Model->getBatch('id = ' . $recordId);
|
public
integer
|
#
get_customers_role_id( )
Get the customers role id from the database.
Get the customers role id from the database.
Returns
integer Returns the role id for the customer records.
|