Code Duplication    Length = 25-26 lines in 2 locations

sources/database/Db-mysql.class.php 1 location

@@ 206-230 (lines=25) @@
203
			$clean = '';
204
			$old_pos = 0;
205
			$pos = -1;
206
			while (true)
207
			{
208
				$pos = strpos($db_string, '\'', $pos + 1);
209
				if ($pos === false)
210
					break;
211
				$clean .= substr($db_string, $old_pos, $pos - $old_pos);
212
213
				while (true)
214
				{
215
					$pos1 = strpos($db_string, '\'', $pos + 1);
216
					$pos2 = strpos($db_string, '\\', $pos + 1);
217
					if ($pos1 === false)
218
						break;
219
					elseif ($pos2 === false || $pos2 > $pos1)
220
					{
221
						$pos = $pos1;
222
						break;
223
					}
224
225
					$pos = $pos2 + 1;
226
				}
227
228
				$clean .= ' %s ';
229
				$old_pos = $pos + 1;
230
			}
231
232
			$clean .= substr($db_string, $old_pos);
233
			$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));

sources/database/Db-postgresql.class.php 1 location

@@ 256-281 (lines=26) @@
253
			$clean = '';
254
			$old_pos = 0;
255
			$pos = -1;
256
			while (true)
257
			{
258
				$pos = strpos($db_string, '\'', $pos + 1);
259
				if ($pos === false)
260
					break;
261
				$clean .= substr($db_string, $old_pos, $pos - $old_pos);
262
263
				while (true)
264
				{
265
					$pos1 = strpos($db_string, '\'', $pos + 1);
266
					$pos2 = strpos($db_string, '\'\'', $pos + 1);
267
268
					if ($pos1 === false)
269
						break;
270
					elseif ($pos2 === false || $pos2 > $pos1)
271
					{
272
						$pos = $pos1;
273
						break;
274
					}
275
276
					$pos = $pos2 + 1;
277
				}
278
279
				$clean .= ' %s ';
280
				$old_pos = $pos + 1;
281
			}
282
283
			$clean .= substr($db_string, $old_pos);
284
			$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));