-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultSource.php
More file actions
90 lines (74 loc) · 2.35 KB
/
Copy pathResultSource.php
File metadata and controls
90 lines (74 loc) · 2.35 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace plugins\riResultList;
class ResultSource extends \Zepluf\Bundle\StoreBundle\Object implements ResultSourceInterface{
protected $resultList_, $model, $from, $select;
/**
* Set the corresponding result list.
*
* @param ZMResultList resultList The *parent* result list.
*/
public function select($select){
$this->select = $select;
return $this;
}
public function from($from){
$this->from = $from;
return $this;
}
public function setResultList($resultList){
$this->resultList_ = $resultList;
return $this;
}
/**
* Get the results.
*
* @param boolean reload Optional reload flag; default is <code>false</code>.
*
* @return array List of results.
*/
public function getResults($reload=false){
global $db;
$sql = 'SELECT ' . $this->select . ' FROM ' . $this->from;
$sql = $this->resultList_->buildPaginationQuery($sql);
$result = $db->Execute($sql);
$results = array();
while(!$result->EOF){
$results[] = $this->create($result->fields);
$result->MoveNext();
}
return $results;
}
/**
* Get the class name of the results.
*
* @return string The class name of the results.
*/
public function getResultClass(){
}
/**
* Total number of results.
*
* @return int The total number if results.
*/
public function getTotalNumberOfResults(){
global $db;
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->from;
$sql = $this->resultList_->buildBaseQuery($sql);
$result = $db->execute($sql);
return $result->fields['count'];
}
/**
* Indicates whether the returned results are final or not.
*
* <p>Sources may opt to filter and sort results already (for example for performance
* reasons. In that case, no further action is required by the result list.</p>
*
* <p>As a side effect, the method <code>getAllResults()</code> may then return the same
* results (number and sort order) as <code>getResults()</code>, even if the source
* reports more than one page.</p>
*
* @return boolean <code>true</code> if the result source is handling all sorting and filtering, too.
*/
public function isFinal(){
}
}