forked from vgrish/NewsModxBox
/
getdata.class.php
65 lines (53 loc) · 2.01 KB
/
getdata.class.php
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
<?php
/*
* return products data array
*/
require_once dirname(__FILE__).'/getlist.class.php';
class modSiteWebGetdataProcessor extends modSiteWebGetlistProcessor{
public function iterate(array $data) {
$list = $this->beforeIteration($data['results']);
$list = $this->afterIteration($list);
return $list;
}
public function afterIteration(array $list) {
$_list = parent::afterIteration($list);
$list = array();
foreach($_list as & $l){
$l['id'] = $l['object_id'];
$list[$l['id']] = $l;
}
return $list;
}
protected function getResults(xPDOQuery & $c){
$list = array();
$this->currentIndex = 0;
if($c->prepare()){
if($c->stmt->execute()){
while($row = $c->stmt->fetch(PDO::FETCH_ASSOC)){
$object_id = $row['object_id'];
if(empty($list[$object_id])){
$list[$object_id] = $row;
$list[$object_id]['tvs'] = array();
$this->currentIndex++;
}
if(!empty($row['tv_name'])){
$list[$object_id]['tvs'][$row['tv_name']] = array(
'tv_id' => $row['tv_id'],
'value_id' => $row['tv_value_id'],
'value' => $row['tv_value'],
);
}
}
}
else{
if($c->stmt->errorCode() !== "00000"){
$this->modx->log(xPDO::LOG_LEVEL_ERROR, __CLASS__);
$this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($c->stmt->errorInfo(), true));
$this->modx->log(xPDO::LOG_LEVEL_ERROR, $c->toSQL());
}
}
}
return $list;
}
}
return 'modSiteWebGetdataProcessor';