ActiveRecord.php
863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Common model function
*
*/
abstract class ActiveRecord extends CActiveRecord
{
/**
* @param integer, record start
* @param integer, record limit number
*/
public function limited($start = 0, $limit = 100)
{
$this->getDbCriteria()->mergeWith(array(
'offset' => $start,
'limit' => $limit
));
return $this;
}
/**
* Finds out sort parameters
*/
public static function getSort( $sort )
{
if(!is_array($sort) || count($sort) == 0) {
return '';
}
$_str = array();
array_walk($sort, create_function('$item, $key, $_tmp', '
$_tmp[0][] = $item["property"] . " " . $item["direction"];
'), array( &$_str ));
return implode(", ", $_str);
}
}