PHP Class ModelSearch

Inheritance: extends Model
Mostra file Open project: openeyes/openeyes Class Usage Examples

Protected Properties

Property Type Description
$criteria CDbCriteria
$itemsPerPage integer
$model BaseActiveRecord
$request Request
$searchItems array
$searchTerms array

Public Methods

Method Description
__construct ( BaseActiveRecord $model )
addActiveFilter ( )
addSearchItem ( $key, string | array $search = '' ) Add a search item.
getCriteria ( ) : CDbCriteria
getItemsPerPage ( ) : integer
getModel ( ) : BaseActiveRecord
getRequest ( ) : mixed
getSearchItems ( ) : array
getSearchTermForAttribute ( $attribute, string $default = '' ) : string Retrieves the search term supplied by the user for a given attribute if there was one.
initPagination ( ) : CPagination Inits pagination for the results and returns it.
initSearch ( $searchInput )
retrieveResults ( ) : CActiveRecord[] Performs the query that has been generated.
setCriteria ( CDbCriteria $criteria )
setItemsPerPage ( integer $itemsPerPage )
setModel ( BaseActiveRecord $model )
setRequest ( mixed $request )
setSearchItems ( array $searchItems )

Protected Methods

Method Description
addCompare ( CDbCriteria $criteria, $attribute, $value, boolean $sensitive = false, string $operator = 'AND', $exactmatch = false ) Adds a comparison between a search term and an attribute.
generateCriteria ( string | array $attr = 'search' ) Generates the required Criteria object for the search.
relationalAttribute ( CDbCriteria $criteria, string $attribute, string $search ) : string Takes an attribute name and makes sure appropriate relationships are included.

Method Details

__construct() public method

public __construct ( BaseActiveRecord $model )
$model BaseActiveRecord

addActiveFilter() public method

public addActiveFilter ( )

addCompare() protected method

Adds a comparison between a search term and an attribute.
protected addCompare ( CDbCriteria $criteria, $attribute, $value, boolean $sensitive = false, string $operator = 'AND', $exactmatch = false )
$criteria CDbCriteria
$attribute
$value
$sensitive boolean
$operator string

addSearchItem() public method

Add a search item.
public addSearchItem ( $key, string | array $search = '' )
$key
$search string | array

generateCriteria() protected method

Generates the required Criteria object for the search.
protected generateCriteria ( string | array $attr = 'search' )
$attr string | array

getCriteria() public method

public getCriteria ( ) : CDbCriteria
return CDbCriteria

getItemsPerPage() public method

public getItemsPerPage ( ) : integer
return integer

getModel() public method

public getModel ( ) : BaseActiveRecord
return BaseActiveRecord

getRequest() public method

public getRequest ( ) : mixed
return mixed

getSearchItems() public method

public getSearchItems ( ) : array
return array

getSearchTermForAttribute() public method

Retrieves the search term supplied by the user for a given attribute if there was one.
public getSearchTermForAttribute ( $attribute, string $default = '' ) : string
$attribute
$default string
return string

initPagination() public method

Inits pagination for the results and returns it.
public initPagination ( ) : CPagination
return CPagination

initSearch() public method

public initSearch ( $searchInput )
$searchInput

relationalAttribute() protected method

This will take an attribute name many layers of relationship deep, make sure that all appropriate tables are included with the result and return a string that is then acceptable to be used in a where clause.
protected relationalAttribute ( CDbCriteria $criteria, string $attribute, string $search ) : string
$criteria CDbCriteria
$attribute string
$search string
return string

retrieveResults() public method

Performs the query that has been generated.
public retrieveResults ( ) : CActiveRecord[]
return CActiveRecord[]

setCriteria() public method

public setCriteria ( CDbCriteria $criteria )
$criteria CDbCriteria

setItemsPerPage() public method

public setItemsPerPage ( integer $itemsPerPage )
$itemsPerPage integer

setModel() public method

public setModel ( BaseActiveRecord $model )
$model BaseActiveRecord

setRequest() public method

public setRequest ( mixed $request )
$request mixed

setSearchItems() public method

public setSearchItems ( array $searchItems )
$searchItems array

Property Details

$criteria protected_oe property

protected CDbCriteria $criteria
return CDbCriteria

$itemsPerPage protected_oe property

protected int $itemsPerPage
return integer

$model protected_oe property

protected BaseActiveRecord $model
return BaseActiveRecord

$request protected_oe property

protected Request $request
return Request

$searchItems protected_oe property

protected array $searchItems
return array

$searchTerms protected_oe property

protected array $searchTerms
return array