summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-03-15 22:55:57 +0100
committeremkael <emkael@tlen.pl>2016-03-15 22:55:57 +0100
commita7b9899d1b227a7ea9d0019bdc07905c9eb12482 (patch)
treeabe7d52eefe6f538f541e26ad21b9ef47ac929bd
parentf2459057389f7bbb751eaf325d1783c15f856ebc (diff)
* facades for sql maps
-rw-r--r--app/php/application.xml1
-rw-r--r--app/php/facades/Facade.php43
-rw-r--r--app/php/facades/config.xml10
-rw-r--r--app/php/sqlmap/config.xml8
4 files changed, 62 insertions, 0 deletions
diff --git a/app/php/application.xml b/app/php/application.xml
index 409f957..3c378bd 100644
--- a/app/php/application.xml
+++ b/app/php/application.xml
@@ -3,6 +3,7 @@
<include file="Application.db.config" />
<include file="Application.model.config" />
+ <include file="Application.facades.config" />
<include file="Application.user.config" />
<include file="Application.url.config" />
<include file="Application.components.config" />
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);
+ }
+
+}
+
+?>
diff --git a/app/php/facades/config.xml b/app/php/facades/config.xml
new file mode 100644
index 0000000..8d5a298
--- /dev/null
+++ b/app/php/facades/config.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <modules>
+ <module id="sqlmap"
+ class="System.Data.SqlMap.TSqlMapConfig"
+ ConnectionID="db"
+ ConfigFile="Application.sqlmap.config"
+ EnableCache="true" />
+ </modules>
+</configuration>
diff --git a/app/php/sqlmap/config.xml b/app/php/sqlmap/config.xml
new file mode 100644
index 0000000..7c213a3
--- /dev/null
+++ b/app/php/sqlmap/config.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<sqlMapConfig>
+ <provider class="TAdodbProvider">
+ <datasource ConnectionID="db" />
+ </provider>
+ <sqlMaps>
+ </sqlMaps>
+</sqlMapConfig>