Resource::search PHP Method

    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.
        $criteria = new CDbCriteria();
        $criteria->compare('resource_id', $this->resource_id, true);
        $criteria->compare('resource_name', $this->resource_name, true);
        $criteria->compare('resource_body', $this->resource_body, true);
        $criteria->compare('resource_path', $this->resource_path, true);
        $criteria->compare('resource_type', $this->resource_type, true);
        $criteria->compare('created', $this->created);
        $criteria->compare('updated', $this->updated);
        $criteria->compare('creator', $this->creator, true);
        $sort = new CSort();
        $sort->attributes = array('resource_id');
        $sort->defaultOrder = 'resource_id DESC';
        return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'sort' => $sort));
    }

Usage Example

if ($page == '1') {
    $startingRecNumber = 0;
} else {
    $startingRecNumber = $page * $recordsPerPage - $recordsPerPage;
}
//get total number of records to print out and calculate page selectors
$resourceObj = new Resource();
$totalRecords = $resourceObj->searchCount($whereAdd);
//reset pagestart to 1 - happens when a new search is run but it kept the old page start
if ($totalRecords < $startingRecNumber) {
    $page = 1;
    $startingRecNumber = 1;
}
$limit = $startingRecNumber . ", " . $recordsPerPage;
$resourceArray = array();
$resourceArray = $resourceObj->search($whereAdd, $orderBy, $limit);
if (count($resourceArray) == 0) {
    echo "<br /><br /><i>Sorry, no requests fit your query</i>";
    $i = 0;
} else {
    //maximum number of pages to display on screen at one time
    $maxDisplay = 25;
    $displayStartingRecNumber = $startingRecNumber + 1;
    $displayEndingRecNumber = $startingRecNumber + $recordsPerPage;
    if ($displayEndingRecNumber > $totalRecords) {
        $displayEndingRecNumber = $totalRecords;
    }
    //div for displaying record count
    echo "<span style='float:left; font-weight:bold; width:650px;'>Displaying " . $displayStartingRecNumber . " to " . $displayEndingRecNumber . " of " . $totalRecords . " Resource Records</span><span style='float:right;width:20px;'><a href='javascript:void(0);'><img src='images/xls.gif' id='export'></a></span>";
    //print out page selectors as long as there are more records than the number that should be displayed
    if ($totalRecords > $recordsPerPage) {