blob: 8317822676f8aa1a394e596b3958b98b11982fdf (
plain)
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
|
<?php
Prado::using('System.Data.SqlMap.TSqlMapGateway');
class Facade {
protected static $_instances = [];
protected $_sqlMap;
protected function __construct() {
}
public function __sleep() {
$this->_sqlMap = NULL;
return array();
}
public static function getInstance() {
$className = get_called_class();
if (!isset(static::$_instances[$className])) {
static::$_instances[$className] = new static();
}
return static::$_instances[$className];
}
protected function getClient() {
if (!$this->_sqlMap) {
$this->_sqlMap = Prado::getApplication()->getModule('sqlmap')->Client;
}
return $this->_sqlMap;
}
protected function quoteString(string $string) {
return $this->getClient()->DbConnection->quoteString($string);
}
protected function fetch(string $sqlMap, array $params) {
return $this->getClient()->queryForObject($sqlMap, $params);
}
protected function fetchList(string $sqlMap, array $params) {
return $this->getClient()->queryForList($sqlMap, $params);
}
protected function fetchMap(string $sqlMap, array $params, string $key, $value=NULL) {
return $this->getClient()->queryForMap($sqlMap, $params, $key, $value);
}
protected function beginTransaction() {
return $this->getClient()->DbConnection->beginTransaction();
}
protected function raiseEvent(string $event, ...$params) {
return Prado::getApplication()->getModule('events')->raiseApplicationEvent(
$event, ...$params
);
}
}
?>
|