@@ 124-171 (lines=48) @@ | ||
121 | return '['.str_replace('.', '[.]', $table).']'; |
|
122 | } |
|
123 | ||
124 | public function escape_column($column) |
|
125 | { |
|
126 | if (!$this->db_config['escape']) { |
|
127 | return $column; |
|
128 | } |
|
129 | ||
130 | if ($column == '*') { |
|
131 | return $column; |
|
132 | } |
|
133 | ||
134 | // This matches any functions we support to SELECT. |
|
135 | if (preg_match('/(avg|count|sum|max|min)\(\s*(.*)\s*\)(\s*as\s*(.+)?)?/i', $column, $matches)) { |
|
136 | if (count($matches) == 3) { |
|
137 | return $matches[1].'('.$this->escape_column($matches[2]).')'; |
|
138 | } elseif (count($matches) == 5) { |
|
139 | return $matches[1].'('.$this->escape_column($matches[2]).') AS '.$this->escape_column($matches[2]); |
|
140 | } |
|
141 | } |
|
142 | ||
143 | // This matches any modifiers we support to SELECT. |
|
144 | if (! preg_match('/\b(?:rand|all|distinct(?:row)?|high_priority|sql_(?:small_result|b(?:ig_result|uffer_result)|no_cache|ca(?:che|lc_found_rows)))\s/i', $column)) { |
|
145 | if (stripos($column, ' AS ') !== false) { |
|
146 | // Force 'AS' to uppercase |
|
147 | $column = str_ireplace(' AS ', ' AS ', $column); |
|
148 | ||
149 | // Runs escape_column on both sides of an AS statement |
|
150 | $column = array_map(array($this, __FUNCTION__), explode(' AS ', $column)); |
|
151 | ||
152 | // Re-create the AS statement |
|
153 | return implode(' AS ', $column); |
|
154 | } |
|
155 | ||
156 | return preg_replace('/[^.*]+/', '[$0]', $column); |
|
157 | } |
|
158 | ||
159 | $parts = explode(' ', $column); |
|
160 | $column = ''; |
|
161 | ||
162 | for ($i = 0, $c = count($parts); $i < $c; $i++) { |
|
163 | // The column is always last |
|
164 | if ($i == ($c - 1)) { |
|
165 | $column .= preg_replace('/[^.*]+/', '[$0]', $parts[$i]); |
|
166 | } else { // otherwise, it's a modifier |
|
167 | $column .= $parts[$i].' '; |
|
168 | } |
|
169 | } |
|
170 | return $column; |
|
171 | } |
|
172 | ||
173 | /** |
|
174 | * Limit in SQL Server 2000 only uses the keyword |
@@ 125-172 (lines=48) @@ | ||
122 | return '`'.str_replace('.', '`.`', $table).'`'; |
|
123 | } |
|
124 | ||
125 | public function escape_column($column) |
|
126 | { |
|
127 | if (!$this->db_config['escape']) { |
|
128 | return $column; |
|
129 | } |
|
130 | ||
131 | if ($column == '*') { |
|
132 | return $column; |
|
133 | } |
|
134 | ||
135 | // This matches any functions we support to SELECT. |
|
136 | if (preg_match('/(avg|count|sum|max|min)\(\s*(.*)\s*\)(\s*as\s*(.+)?)?/i', $column, $matches)) { |
|
137 | if (count($matches) == 3) { |
|
138 | return $matches[1].'('.$this->escape_column($matches[2]).')'; |
|
139 | } elseif (count($matches) == 5) { |
|
140 | return $matches[1].'('.$this->escape_column($matches[2]).') AS '.$this->escape_column($matches[2]); |
|
141 | } |
|
142 | } |
|
143 | ||
144 | // This matches any modifiers we support to SELECT. |
|
145 | if (! preg_match('/\b(?:rand|all|distinct(?:row)?|high_priority|sql_(?:small_result|b(?:ig_result|uffer_result)|no_cache|ca(?:che|lc_found_rows)))\s/i', $column)) { |
|
146 | if (stripos($column, ' AS ') !== false) { |
|
147 | // Force 'AS' to uppercase |
|
148 | $column = str_ireplace(' AS ', ' AS ', $column); |
|
149 | ||
150 | // Runs escape_column on both sides of an AS statement |
|
151 | $column = array_map(array($this, __FUNCTION__), explode(' AS ', $column)); |
|
152 | ||
153 | // Re-create the AS statement |
|
154 | return implode(' AS ', $column); |
|
155 | } |
|
156 | ||
157 | return preg_replace('/[^.*]+/', '`$0`', $column); |
|
158 | } |
|
159 | ||
160 | $parts = explode(' ', $column); |
|
161 | $column = ''; |
|
162 | ||
163 | for ($i = 0, $c = count($parts); $i < $c; $i++) { |
|
164 | // The column is always last |
|
165 | if ($i == ($c - 1)) { |
|
166 | $column .= preg_replace('/[^.*]+/', '`$0`', $parts[$i]); |
|
167 | } else { // otherwise, it's a modifier |
|
168 | $column .= $parts[$i].' '; |
|
169 | } |
|
170 | } |
|
171 | return $column; |
|
172 | } |
|
173 | ||
174 | public function regex($field, $match, $type, $num_regexs) |
|
175 | { |
@@ 88-135 (lines=48) @@ | ||
85 | return '`'.str_replace('.', '`.`', $table).'`'; |
|
86 | } |
|
87 | ||
88 | public function escape_column($column) |
|
89 | { |
|
90 | if (! $this->db_config['escape']) { |
|
91 | return $column; |
|
92 | } |
|
93 | ||
94 | if ($column == '*') { |
|
95 | return $column; |
|
96 | } |
|
97 | ||
98 | // This matches any functions we support to SELECT. |
|
99 | if (preg_match('/(avg|count|sum|max|min)\(\s*(.*)\s*\)(\s*as\s*(.+)?)?/i', $column, $matches)) { |
|
100 | if (count($matches) == 3) { |
|
101 | return $matches[1].'('.$this->escape_column($matches[2]).')'; |
|
102 | } elseif (count($matches) == 5) { |
|
103 | return $matches[1].'('.$this->escape_column($matches[2]).') AS '.$this->escape_column($matches[2]); |
|
104 | } |
|
105 | } |
|
106 | ||
107 | // This matches any modifiers we support to SELECT. |
|
108 | if (! preg_match('/\b(?:rand|all|distinct(?:row)?|high_priority|sql_(?:small_result|b(?:ig_result|uffer_result)|no_cache|ca(?:che|lc_found_rows)))\s/i', $column)) { |
|
109 | if (stripos($column, ' AS ') !== false) { |
|
110 | // Force 'AS' to uppercase |
|
111 | $column = str_ireplace(' AS ', ' AS ', $column); |
|
112 | ||
113 | // Runs escape_column on both sides of an AS statement |
|
114 | $column = array_map(array($this, __FUNCTION__), explode(' AS ', $column)); |
|
115 | ||
116 | // Re-create the AS statement |
|
117 | return implode(' AS ', $column); |
|
118 | } |
|
119 | ||
120 | return preg_replace('/[^.*]+/', '`$0`', $column); |
|
121 | } |
|
122 | ||
123 | $parts = explode(' ', $column); |
|
124 | $column = ''; |
|
125 | ||
126 | for ($i = 0, $c = count($parts); $i < $c; $i++) { |
|
127 | // The column is always last |
|
128 | if ($i == ($c - 1)) { |
|
129 | $column .= preg_replace('/[^.*]+/', '`$0`', $parts[$i]); |
|
130 | } else { // otherwise, it's a modifier |
|
131 | $column .= $parts[$i].' '; |
|
132 | } |
|
133 | } |
|
134 | return $column; |
|
135 | } |
|
136 | ||
137 | public function limit($limit, $offset = 0) |
|
138 | { |
@@ 102-149 (lines=48) @@ | ||
99 | return '"'.str_replace('.', '"."', $table).'"'; |
|
100 | } |
|
101 | ||
102 | public function escape_column($column) |
|
103 | { |
|
104 | if (!$this->db_config['escape']) { |
|
105 | return $column; |
|
106 | } |
|
107 | ||
108 | if ($column == '*') { |
|
109 | return $column; |
|
110 | } |
|
111 | ||
112 | // This matches any functions we support to SELECT. |
|
113 | if (preg_match('/(avg|count|sum|max|min)\(\s*(.*)\s*\)(\s*as\s*(.+)?)?/i', $column, $matches)) { |
|
114 | if (count($matches) == 3) { |
|
115 | return $matches[1].'('.$this->escape_column($matches[2]).')'; |
|
116 | } elseif (count($matches) == 5) { |
|
117 | return $matches[1].'('.$this->escape_column($matches[2]).') AS '.$this->escape_column($matches[2]); |
|
118 | } |
|
119 | } |
|
120 | ||
121 | // This matches any modifiers we support to SELECT. |
|
122 | if (! preg_match('/\b(?:all|distinct)\s/i', $column)) { |
|
123 | if (stripos($column, ' AS ') !== false) { |
|
124 | // Force 'AS' to uppercase |
|
125 | $column = str_ireplace(' AS ', ' AS ', $column); |
|
126 | ||
127 | // Runs escape_column on both sides of an AS statement |
|
128 | $column = array_map(array($this, __FUNCTION__), explode(' AS ', $column)); |
|
129 | ||
130 | // Re-create the AS statement |
|
131 | return implode(' AS ', $column); |
|
132 | } |
|
133 | ||
134 | return preg_replace('/[^.*]+/', '"$0"', $column); |
|
135 | } |
|
136 | ||
137 | $parts = explode(' ', $column); |
|
138 | $column = ''; |
|
139 | ||
140 | for ($i = 0, $c = count($parts); $i < $c; $i++) { |
|
141 | // The column is always last |
|
142 | if ($i == ($c - 1)) { |
|
143 | $column .= preg_replace('/[^.*]+/', '"$0"', $parts[$i]); |
|
144 | } else { // otherwise, it's a modifier |
|
145 | $column .= $parts[$i].' '; |
|
146 | } |
|
147 | } |
|
148 | return $column; |
|
149 | } |
|
150 | ||
151 | public function regex($field, $match, $type, $num_regexs) |
|
152 | { |