diff options
author | emkael <emkael@tlen.pl> | 2016-03-15 22:55:57 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-15 22:55:57 +0100 |
commit | a7b9899d1b227a7ea9d0019bdc07905c9eb12482 (patch) | |
tree | abe7d52eefe6f538f541e26ad21b9ef47ac929bd /app/php/facades/Facade.php | |
parent | f2459057389f7bbb751eaf325d1783c15f856ebc (diff) |
* facades for sql maps
Diffstat (limited to 'app/php/facades/Facade.php')
-rw-r--r-- | app/php/facades/Facade.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/php/facades/Facade.php b/app/php/facades/Facade.php new file mode 100644 index 0000000..5d71a89 --- /dev/null +++ b/app/php/facades/Facade.php @@ -0,0 +1,43 @@ +<?php + +class Facade { + + protected static $_instances = array(); + + 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); + } + +} + +?> |