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
91
92
93
94
95
96
97
98
<?php
namespace Application\Model\Test\Storage;
use Application\Model\Test\Storage;
use Khansia\Generic\Result as Result;
use Zend\Db\ResultSet\ResultSet;
class Mysql extends \Khansia\Db\Storage implements Skeleton {
private $_result;
const LOP = 'lop_cluster';
const JOIN_LEFT = 'left';
public function array_change_key_case_recursive($input, $case = CASE_LOWER){
if(!is_array($input)){
trigger_error("Invalid input array '{$array}'",E_USER_NOTICE); exit;
}
// CASE_UPPER|CASE_LOWER
if(null === $case){
$case = CASE_LOWER;
}
if(!in_array($case, array(CASE_UPPER, CASE_LOWER))){
trigger_error("Case parameter '{$case}' is invalid.", E_USER_NOTICE); exit;
}
$input = array_change_key_case($input, $case);
foreach($input as $key=>$array){
if(is_array($array)){
$input[$key] = $this->array_change_key_case_recursive($array, $case);
}
}
return $input;
}
public function __construct(\Zend\Db\Adapter\Adapter $adapter, $config = array()) {
parent::__construct($adapter, $config);
/* get conn instance */
$this->_conn = $adapter->getDriver()->getConnection()->getResource();
//print_r($config);
if (isset($config['tables'])) {
$tables = $config['tables'];
foreach ($tables as $key => $value) {
if (array_key_exists($key, $this->_tables) && $value) {
$this->_tables[$key] = $this->_($value);
}
}
}
}
public function fetchAll(\Zend\Db\Sql\Select $select, $raw = true){
$statement = $this->_sql->prepareStatementForSqlObject($select);
if ($result = $statement->execute()) {
$resultset = new \Zend\Db\ResultSet\ResultSet();
$data = $resultset->initialize($result)->toArray();
return $data;
}
return false;
}
public function loadDataTest(){
$result = new Result();
try {
$sql = " select * from user_data_header limit 10 ";
$stmt = $this->_db->query($sql);
$resdata = $stmt->execute();
$listdata = array();
while($resdata->next()){
$res = $resdata->current();
array_push($listdata,$res);
}
//print_r($paramGroup);die;
if ($listdata) {
$result->code = 0;
$result->info = 'OK';
$result->data = $listdata;
} else {
$result->code = 1;
$result->info = 'nok';
}
}catch (\Zend\Db\Adapter\Exception\RuntimeException $ex) {
$result->code = 3;
$result->info = 'ERROR : ' . $ex->getMessage();
} catch (\Exception $ex) {
$result->code = 4;
$result->info = 'ERROR : ' . $ex->getMessage();
}
return $result;
}
}