summaryrefslogtreecommitdiff
path: root/app/php/facades/Facade.php
blob: 742365cf995ba837173f7db196cea083de7c0021 (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
<?php

class Facade {

    protected static $_instances = [];

    protected $_sqlMap;

    protected function __construct() {
        $this->_sqlMap = Prado::getApplication()->getModule('sqlmap')->Client;
    }

    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() {
        return $this->_sqlMap;
    }

    protected function quoteString($string) {
        return $this->getClient()->DbConnection->quoteString($string);
    }

    protected function fetch($sqlMap, $params) {
        return $this->getClient()->queryForObject($sqlMap, $params);
    }

    protected function fetchList($sqlMap, $params) {
        return $this->getClient()->queryForList($sqlMap, $params);
    }

    protected function fetchMap($sqlMap, $params, $key, $value=NULL) {
        return $this->getClient()->queryForMap($sqlMap, $params, $key, $value);
    }

}

?>