@@ -22,33 +22,33 @@ |
||
22 | 22 | private $_parameterNames; |
23 | 23 | private $_parameterValues; |
24 | 24 | |
25 | - public function getPreparedSql(){ return $this->_sqlString; } |
|
26 | - public function setPreparedSql($value){ $this->_sqlString = $value; } |
|
25 | + public function getPreparedSql() { return $this->_sqlString; } |
|
26 | + public function setPreparedSql($value) { $this->_sqlString=$value; } |
|
27 | 27 | |
28 | - public function getParameterNames($needed = true) |
|
28 | + public function getParameterNames($needed=true) |
|
29 | 29 | { |
30 | - if (!$this->_parameterNames and $needed) |
|
31 | - $this->_parameterNames = new TList; |
|
30 | + if(!$this->_parameterNames and $needed) |
|
31 | + $this->_parameterNames=new TList; |
|
32 | 32 | return $this->_parameterNames; |
33 | 33 | } |
34 | 34 | |
35 | - public function setParameterNames($value){ $this->_parameterNames = $value; } |
|
35 | + public function setParameterNames($value) { $this->_parameterNames=$value; } |
|
36 | 36 | |
37 | - public function getParameterValues($needed = true) |
|
37 | + public function getParameterValues($needed=true) |
|
38 | 38 | { |
39 | - if (!$this->_parameterValues and $needed) |
|
39 | + if(!$this->_parameterValues and $needed) |
|
40 | 40 | $this->_parameterValues=new TMap; |
41 | 41 | return $this->_parameterValues; |
42 | 42 | } |
43 | 43 | |
44 | - public function setParameterValues($value){ $this->_parameterValues = $value; } |
|
44 | + public function setParameterValues($value) { $this->_parameterValues=$value; } |
|
45 | 45 | |
46 | 46 | public function __sleep() |
47 | 47 | { |
48 | - $exprops = array(); $cn = __CLASS__; |
|
49 | - if (!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames"; |
|
50 | - if (!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues"; |
|
51 | - return array_diff(parent::__sleep(),$exprops); |
|
48 | + $exprops=array(); $cn=__CLASS__; |
|
49 | + if(!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[]="\0$cn\0_parameterNames"; |
|
50 | + if(!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[]="\0$cn\0_parameterValues"; |
|
51 | + return array_diff(parent::__sleep(), $exprops); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 |
@@ -21,45 +21,45 @@ |
||
21 | 21 | */ |
22 | 22 | class TPreparedCommand |
23 | 23 | { |
24 | - public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
|
24 | + public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject, $skip=null, $max=null) |
|
25 | 25 | { |
26 | - $sqlText = $statement->getSQLText(); |
|
26 | + $sqlText=$statement->getSQLText(); |
|
27 | 27 | |
28 | - $prepared = $sqlText->getPreparedStatement($parameterObject); |
|
28 | + $prepared=$sqlText->getPreparedStatement($parameterObject); |
|
29 | 29 | $connection->setActive(true); |
30 | - $sql = $prepared->getPreparedSql(); |
|
30 | + $sql=$prepared->getPreparedSql(); |
|
31 | 31 | |
32 | 32 | if($sqlText instanceof TSimpleDynamicSql) |
33 | - $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
33 | + $sql=$sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
34 | 34 | |
35 | 35 | if($max!==null || $skip!==null) |
36 | 36 | { |
37 | - $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
38 | - $sql = $builder->applyLimitOffset($sql,$max,$skip); |
|
37 | + $builder=TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
38 | + $sql=$builder->applyLimitOffset($sql, $max, $skip); |
|
39 | 39 | } |
40 | - $command = $connection->createCommand($sql); |
|
40 | + $command=$connection->createCommand($sql); |
|
41 | 41 | $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject); |
42 | 42 | |
43 | 43 | return $command; |
44 | 44 | } |
45 | 45 | |
46 | - protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
|
46 | + protected function applyParameterMap($manager, $command, $prepared, $statement, $parameterObject) |
|
47 | 47 | { |
48 | - $properties = $prepared->getParameterNames(false); |
|
48 | + $properties=$prepared->getParameterNames(false); |
|
49 | 49 | //$parameters = $prepared->getParameterValues(); |
50 | 50 | $registry=$manager->getTypeHandlers(); |
51 | - if ($properties) |
|
52 | - for($i = 0, $k=$properties->getCount(); $i<$k; $i++) |
|
51 | + if($properties) |
|
52 | + for($i=0, $k=$properties->getCount(); $i < $k; $i++) |
|
53 | 53 | { |
54 | - $property = $statement->parameterMap()->getProperty($i); |
|
55 | - $value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject); |
|
56 | - $dbType = $property->getDbType(); |
|
54 | + $property=$statement->parameterMap()->getProperty($i); |
|
55 | + $value=$statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
|
56 | + $dbType=$property->getDbType(); |
|
57 | 57 | if($dbType=='') //relies on PHP lax comparison |
58 | - $command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value)); |
|
58 | + $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
|
59 | 59 | else if(strpos($dbType, 'PDO::')===0) |
60 | - $command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
60 | + $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
61 | 61 | else |
62 | - $command->bindValue($i+1,$value); |
|
62 | + $command->bindValue($i + 1, $value); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -22,8 +22,8 @@ |
||
22 | 22 | |
23 | 23 | public function buildPreparedStatement($statement, $sqlString) |
24 | 24 | { |
25 | - $factory = new TPreparedStatementFactory($statement, $sqlString); |
|
26 | - $this->_preparedStatement = $factory->prepare(); |
|
25 | + $factory=new TPreparedStatementFactory($statement, $sqlString); |
|
26 | + $this->_preparedStatement=$factory->prepare(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function getPreparedStatement($parameter=null) |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | * @param mixed delegate for each data row retrieved. |
42 | 42 | * @param int number of page to fetch on initialization |
43 | 43 | */ |
44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate=null, $page=0) |
|
45 | 45 | { |
46 | 46 | parent::__construct(); |
47 | 47 | parent::setCustomPaging(true); |
48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
49 | 49 | $this->_delegate=$delegate; |
50 | 50 | } |
51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function initialize($statement, $parameter, $pageSize, $page) |
60 | 60 | { |
61 | - $this->_statement = $statement; |
|
62 | - $this->_parameter = $parameter; |
|
61 | + $this->_statement=$statement; |
|
62 | + $this->_parameter=$parameter; |
|
63 | 63 | $this->setPageSize($pageSize); |
64 | 64 | $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); |
65 | 65 | $this->gotoPage($page); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function fetchDataFromStatement($sender, $param) |
82 | 82 | { |
83 | - $limit = $this->getOffsetAndLimit($param); |
|
84 | - $connection = $this->_statement->getManager()->getDbConnection(); |
|
85 | - $data = $this->_statement->executeQueryForList($connection, |
|
83 | + $limit=$this->getOffsetAndLimit($param); |
|
84 | + $connection=$this->_statement->getManager()->getDbConnection(); |
|
85 | + $data=$this->_statement->executeQueryForList($connection, |
|
86 | 86 | $this->_parameter, null, $limit[0], $limit[1], $this->_delegate); |
87 | 87 | $this->populateData($param, $data); |
88 | 88 | } |
@@ -112,49 +112,49 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function populateData($param, $data) |
114 | 114 | { |
115 | - $total = $data instanceof TList ? $data->getCount() : count($data); |
|
116 | - $pageSize = $this->getPageSize(); |
|
115 | + $total=$data instanceof TList ? $data->getCount() : count($data); |
|
116 | + $pageSize=$this->getPageSize(); |
|
117 | 117 | if($total < 1) |
118 | 118 | { |
119 | 119 | $param->setData($data); |
120 | - $this->_prevPageList = null; |
|
121 | - $this->_nextPageList = null; |
|
120 | + $this->_prevPageList=null; |
|
121 | + $this->_nextPageList=null; |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | if($param->getNewPageIndex() < 1) |
126 | 126 | { |
127 | - $this->_prevPageList = null; |
|
127 | + $this->_prevPageList=null; |
|
128 | 128 | if($total <= $pageSize) |
129 | 129 | { |
130 | 130 | $param->setData($data); |
131 | - $this->_nextPageList = null; |
|
131 | + $this->_nextPageList=null; |
|
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
136 | + $this->_nextPageList=array_slice($data, $pageSize - 1, $total); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
141 | 141 | if($total <= $pageSize) |
142 | 142 | { |
143 | - $this->_prevPageList = array_slice($data, 0, $total); |
|
143 | + $this->_prevPageList=array_slice($data, 0, $total); |
|
144 | 144 | $param->setData(array()); |
145 | - $this->_nextPageList = null; |
|
145 | + $this->_nextPageList=null; |
|
146 | 146 | } |
147 | - else if($total <= $pageSize*2) |
|
147 | + else if($total <= $pageSize * 2) |
|
148 | 148 | { |
149 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
149 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
151 | - $this->_nextPageList = null; |
|
151 | + $this->_nextPageList=null; |
|
152 | 152 | } |
153 | 153 | else |
154 | 154 | { |
155 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
155 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
157 | + $this->_nextPageList=array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function getOffsetAndLimit($param) |
168 | 168 | { |
169 | - $index = $param->getNewPageIndex(); |
|
170 | - $pageSize = $this->getPageSize(); |
|
171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
169 | + $index=$param->getNewPageIndex(); |
|
170 | + $pageSize=$this->getPageSize(); |
|
171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function registerTypeHandler(TSqlMapTypeHandler $handler) |
49 | 49 | { |
50 | - $this->_typeHandlers[$handler->getType()] = $handler; |
|
50 | + $this->_typeHandlers[$handler->getType()]=$handler; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | switch(strtolower($type)) |
91 | 91 | { |
92 | 92 | case 'integer': case 'int': |
93 | - $type = 'integer'; break; |
|
93 | + $type='integer'; break; |
|
94 | 94 | case 'float': case 'double': case 'decimal': |
95 | - $type = 'float'; break; |
|
95 | + $type='float'; break; |
|
96 | 96 | case 'boolean': case 'bool': |
97 | - $type = 'boolean'; break; |
|
97 | + $type='boolean'; break; |
|
98 | 98 | case 'string' : |
99 | - $type = 'string'; break; |
|
99 | + $type='string'; break; |
|
100 | 100 | default: |
101 | 101 | return $value; |
102 | 102 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct($cacheModel=null) |
28 | 28 | { |
29 | - $this->_cacheModel = $cacheModel; |
|
29 | + $this->_cacheModel=$cacheModel; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | protected function getBaseKeyKeyName() |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | protected function getBaseKey() |
38 | 38 | { |
39 | - $cache = $this->getCache(); |
|
40 | - $keyname = $this->getBaseKeyKeyName(); |
|
41 | - $basekey = $cache->get($keyname); |
|
42 | - if (!$basekey) |
|
39 | + $cache=$this->getCache(); |
|
40 | + $keyname=$this->getBaseKeyKeyName(); |
|
41 | + $basekey=$cache->get($keyname); |
|
42 | + if(!$basekey) |
|
43 | 43 | { |
44 | - $basekey = DxUtil::generateRandomHash(8); |
|
45 | - $cache->set($keyname,$basekey); |
|
44 | + $basekey=DxUtil::generateRandomHash(8); |
|
45 | + $cache->set($keyname, $basekey); |
|
46 | 46 | } |
47 | 47 | return $basekey; |
48 | 48 | } |
@@ -64,23 +64,23 @@ discard block |
||
64 | 64 | |
65 | 65 | public function get($key) |
66 | 66 | { |
67 | - $result = $this->getCache()->get($this->getCacheKey($key)); |
|
68 | - return $result === false ? null : $result; |
|
67 | + $result=$this->getCache()->get($this->getCacheKey($key)); |
|
68 | + return $result===false ? null : $result; |
|
69 | 69 | } |
70 | 70 | |
71 | - public function set($key, $value,$expire=0,$dependency=null) |
|
71 | + public function set($key, $value, $expire=0, $dependency=null) |
|
72 | 72 | { |
73 | - $this->getCache()->set($this->getCacheKey($key), $value, $expire,$dependency); |
|
73 | + $this->getCache()->set($this->getCacheKey($key), $value, $expire, $dependency); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | protected function getCache() |
77 | 77 | { |
78 | - if (!$this->_cache) |
|
79 | - $this->_cache = Prado::getApplication()->getCache(); |
|
78 | + if(!$this->_cache) |
|
79 | + $this->_cache=Prado::getApplication()->getCache(); |
|
80 | 80 | return $this->_cache; |
81 | 81 | } |
82 | 82 | |
83 | - public function add($id,$value,$expire=0,$dependency=null) |
|
83 | + public function add($id, $value, $expire=0, $dependency=null) |
|
84 | 84 | { |
85 | 85 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
86 | 86 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function setTypeHandler($value) |
51 | 51 | { |
52 | - $this->_typeHandler = $value; |
|
52 | + $this->_typeHandler=$value; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function setType($value) |
67 | 67 | { |
68 | - $this->_type = $value; |
|
68 | + $this->_type=$value; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setColumn($value) |
83 | 83 | { |
84 | - $this->_column = $value; |
|
84 | + $this->_column=$value; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function setDbType($value) |
99 | 99 | { |
100 | - $this->_dbType = $value; |
|
100 | + $this->_dbType=$value; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function setProperty($value) |
115 | 115 | { |
116 | - $this->_property = $value; |
|
116 | + $this->_property=$value; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setNullValue($value) |
132 | 132 | { |
133 | - $this->_nullValue = $value; |
|
133 | + $this->_nullValue=$value; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function __sleep() |
137 | 137 | { |
138 | - $exprops = array(); $cn = 'TParameterProperty'; |
|
139 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
140 | - if ($this->_type===null) $exprops[] = "\0$cn\0_type"; |
|
141 | - if ($this->_column===null) $exprops[] = "\0$cn\0_column"; |
|
142 | - if ($this->_dbType===null) $exprops[] = "\0$cn\0_dbType"; |
|
143 | - if ($this->_property===null) $exprops[] = "\0$cn\0_property"; |
|
144 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
145 | - return array_diff(parent::__sleep(),$exprops); |
|
138 | + $exprops=array(); $cn='TParameterProperty'; |
|
139 | + if($this->_typeHandler===null) $exprops[]="\0$cn\0_typeHandler"; |
|
140 | + if($this->_type===null) $exprops[]="\0$cn\0_type"; |
|
141 | + if($this->_column===null) $exprops[]="\0$cn\0_column"; |
|
142 | + if($this->_dbType===null) $exprops[]="\0$cn\0_dbType"; |
|
143 | + if($this->_property===null) $exprops[]="\0$cn\0_property"; |
|
144 | + if($this->_nullValue===null) $exprops[]="\0$cn\0_nullValue"; |
|
145 | + return array_diff(parent::__sleep(), $exprops); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setClass($value) |
83 | 83 | { |
84 | - $this->_class = $value; |
|
84 | + $this->_class=$value; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setExtends($value) |
107 | 107 | { |
108 | - $this->_extends = $value; |
|
108 | + $this->_extends=$value; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setGroupBy($value) |
123 | 123 | { |
124 | - $this->_groupBy = $value; |
|
124 | + $this->_groupBy=$value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function setDiscriminator(TDiscriminator $value) |
139 | 139 | { |
140 | - $this->_discriminator = $value; |
|
140 | + $this->_discriminator=$value; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function addResultProperty(TResultProperty $property) |
148 | 148 | { |
149 | - $this->_columns[$property->getProperty()] = $property; |
|
149 | + $this->_columns[$property->getProperty()]=$property; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function createInstanceOfResult($registry) |
159 | 159 | { |
160 | - $handler = $registry->getTypeHandler($this->getClass()); |
|
160 | + $handler=$registry->getTypeHandler($this->getClass()); |
|
161 | 161 | try |
162 | 162 | { |
163 | 163 | if($handler!==null) |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | else |
166 | 166 | return $registry->createInstanceOf($this->getClass()); |
167 | 167 | } |
168 | - catch (TSqlMapException $e) |
|
168 | + catch(TSqlMapException $e) |
|
169 | 169 | { |
170 | 170 | throw new TSqlMapException( |
171 | 171 | 'sqlmap_unable_to_create_new_instance', |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | * @param array row data. |
180 | 180 | * @return TResultMap result sub-map. |
181 | 181 | */ |
182 | - public function resolveSubMap($registry,$row) |
|
182 | + public function resolveSubMap($registry, $row) |
|
183 | 183 | { |
184 | - $subMap = $this; |
|
185 | - if(($disc = $this->getDiscriminator())!==null) |
|
184 | + $subMap=$this; |
|
185 | + if(($disc=$this->getDiscriminator())!==null) |
|
186 | 186 | { |
187 | - $value = $disc->getMapping()->getPropertyValue($registry,$row); |
|
188 | - $subMap = $disc->getSubMap((string)$value); |
|
187 | + $value=$disc->getMapping()->getPropertyValue($registry, $row); |
|
188 | + $subMap=$disc->getSubMap((string) $value); |
|
189 | 189 | |
190 | 190 | if($subMap===null) |
191 | - $subMap = $this; |
|
192 | - else if($subMap !== $this) |
|
193 | - $subMap = $subMap->resolveSubMap($registry,$row); |
|
191 | + $subMap=$this; |
|
192 | + else if($subMap!==$this) |
|
193 | + $subMap=$subMap->resolveSubMap($registry, $row); |
|
194 | 194 | } |
195 | 195 | return $subMap; |
196 | 196 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class TSimpleDynamicParser |
21 | 21 | { |
22 | - const PARAMETER_TOKEN_REGEXP = '/\$([^\$]+)\$/'; |
|
23 | - const DYNAMIC_TOKEN = '`!`'; |
|
22 | + const PARAMETER_TOKEN_REGEXP='/\$([^\$]+)\$/'; |
|
23 | + const DYNAMIC_TOKEN='`!`'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Parse the sql text for dynamic place holders of the form $name$. |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function parse($sqlText) |
31 | 31 | { |
32 | - $matches = array(); |
|
33 | - $mappings = array(); |
|
32 | + $matches=array(); |
|
33 | + $mappings=array(); |
|
34 | 34 | preg_match_all(self::PARAMETER_TOKEN_REGEXP, $sqlText, $matches); |
35 | - for($i = 0, $k=count($matches[1]); $i<$k; $i++) |
|
35 | + for($i=0, $k=count($matches[1]); $i < $k; $i++) |
|
36 | 36 | { |
37 | - $mappings[] = $matches[1][$i]; |
|
38 | - $sqlText = str_replace($matches[0][$i], self::DYNAMIC_TOKEN, $sqlText); |
|
37 | + $mappings[]=$matches[1][$i]; |
|
38 | + $sqlText=str_replace($matches[0][$i], self::DYNAMIC_TOKEN, $sqlText); |
|
39 | 39 | } |
40 | 40 | return array('sql'=>$sqlText, 'parameters'=>$mappings); |
41 | 41 | } |