summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
diff options
context:
space:
mode:
authorwei <>2006-07-23 11:11:21 +0000
committerwei <>2006-07-23 11:11:21 +0000
commitcbb7a11179b9c1c46e35f04d07d6386a44e400b2 (patch)
treedacfc2a5fdbcce3973e228eaca8002ff799e45d1 /framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
parentc0d9d27f16bae2e428225302da144e9cc6d4adc8 (diff)
Update time-tracker demo and add simple dynamic SQLMap
Diffstat (limited to 'framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php')
-rw-r--r--framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php b/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
new file mode 100644
index 00000000..e58d8af8
--- /dev/null
+++ b/framework/DataAccess/SQLMap/Configuration/TSimpleDynamicParser.php
@@ -0,0 +1,23 @@
+<?php
+
+class TSimpleDynamicParser
+{
+ private $PARAMETER_TOKEN_REGEXP = '/\$([^\$]+)\$/';
+
+ const DYNAMIC_TOKEN = '`!`';
+
+ public function parse($sqlMap, $statement, $sqlText, $scope)
+ {
+ $matches = array();
+ $mappings = array();
+ preg_match_all($this->PARAMETER_TOKEN_REGEXP, $sqlText, $matches);
+ for($i = 0, $k=count($matches[1]); $i<$k; $i++)
+ {
+ $mappings[] = $matches[1][$i];
+ $sqlText = str_replace($matches[0][$i], self::DYNAMIC_TOKEN, $sqlText);
+ }
+ return array('sql'=>$sqlText, 'parameters'=>$mappings);
+ }
+}
+
+?> \ No newline at end of file