Class EmailReader
Class EmailReader
Reads email records from the database. This class provides a customizable interface
for reading operations so that it is possible to build different variations in the
EmailRepository class (e.g. "getPending", "findById", "getAll").
-
EmailReader
implements
EmailReaderInterface
Methods summary
public
|
#
__construct( CI_DB_query_builder $db, EmailFactoryInterface $factory )
Class Constructor
Parameters
- $db
- Will be used for database operations.
- $factory
- Will be used for the creation of returned objects.
|
public
EmailCollection
|
#
get( array $conditions = array(), array $limit = array(), array $order = array() )
Get email records filtered by conditions.
Get email records filtered by conditions.
Example: $reader->get(array('email_id' => $customerId), 10, array( array('email_id', 'asc') ));
Parameters
- $conditions
- (optional) Contains conditions with column => value pairs.
- $limit
(optional) Array that contains LIMIT and OFFSET value
e.g. array( 'limit' => 10, 'offset' => 5 )
- $order
(optional) Contains arrays with column, direction pairs
e.g. array( 'column' => 'direction' )
Returns
Implementation of
|
public
EmailCollection
|
#
filter( string $p_keyword, array $limit = array(), array $order = array() )
Filter email records with provided keyword string.
Filter email records with provided keyword string.
Parameters
- $p_keyword
- String to be used for filtering the email records.
- $limit
(optional) Array that contains LIMIT and OFFSET value
e.g. array( 'limit' => 10, 'offset' => 5 )
- $order
(optional) Contains arrays with column, direction pairs
e.g. array( 'column' => 'direction' )
Returns
Implementation of
|
public
integer
|
#
getRecordCount( string $p_filterKeyword = '' )
Get the current count of the email records in the database.
Get the current count of the email records in the database.
This method will quickly return the record count of the "emails" table. It must
be used when we just need the number and not the data, because the "get" or "find"
methods need more time to load and parse the records.
Parameters
- $p_filterKeyword
- (optional) If provided the records will be filtered.
Returns
integer Returns the row number of the email table.
Throws
InvalidArgumentException If the provided argument is not a string.
Implementation of
|
protected
Email
|
#
_createEmailByArray( array $emailDataArray )
Creates an email object out of an array.
Creates an email object out of an array.
This method expects the following values to be present in the array: 'email_id', 'subject',
'content', 'is_pending', 'contacts', 'attachments'. It uses the EmailFactory for creating
email objects.
Parameters
- $emailDataArray
- Contains the database record information.
Returns
Email Returns an object that represents the database record.
Throws
UnexpectedValueException If the 'creation_date' of the email is empty.
|
protected
|
#
_filter( string $p_keyword )
Apply filter rules to email records.
Apply filter rules to email records.
This method will set the SQL filters depending the provided keyword so that one
can "get" the filtered records.
Parameters
- $p_keyword
- Filtering keyword to be applied in the query.
Throws
InvalidArgumentException If the $keyword argument is not a string.
|
protected
|
#
_limit( array $rule )
Apply LIMIT clause to query.
Apply LIMIT clause to query.
Example: $this->_limit( array( 'limit' => 10, 'offset' => 0 ) );
Parameters
- $rule
- Must be an array that contains 'limit' and 'offset' values.
Link
|
protected
|
#
_order( array $rule )
Apply ORDER BY clause to query.
Apply ORDER BY clause to query.
Example: $this->_order( array( 'email_id' => 'desc' ) );
Parameters
- $rule
- Contains column, direction arrays for ordering results.
Link
|