<?php
$query = "SELECT TABLE FROM FZC WHERE TABLE='chandz' AND TABLE=1 OR DIE='52'";
$strpos_where = strpos($query, 'WHERE') + 6;
$strpos_limit = (int) strpos($query, 'LIMIT');
$strpos_group = (int) strpos($query, 'GROUP BY');
$strpos_order = (int) strpos($query, 'ORDER BY');
if($strpos_limit > 0 AND $strpos_limit > $strpos_group AND $strpos_limit > $strpos_order) {
$where = substr($query, $strpos_where, $strpos_limit);
} elseif($strpos_group > 0 AND $strpos_group > $strpos_limit AND $strpos_group > $strpos_order) {
$where = substr($query, $strpos_where, $strpos_group);
} elseif($strpos_order > 0 AND $strpos_order > $strpos_limit AND $strpos_order > $strpos_group) {
$where = substr($query, $strpos_where, $strpos_order);
} else {
$where = substr($query, $strpos_where);
}
$new_query = substr($query, 0, $strpos_where);
$where_built = "";
$where_values = array();
$where_break = explode(' AND ', $where);
$where_break_c = count($where_break);
for($i = 0; $i < $where_break_c; $i++) {
if(!isset($where_break[$i])) {
continue;
}
$clausel = $where_break[$i];
if(isset($where_break[$i + 1]) AND preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $where_break[$i + 1]) != 1) {
$where_break[$i] = $where_break[$i]." AND ".$where_break[$i + 1];
$clausel = $where_break[$i];
unset($where_break[$i + 1]);
}
$where_break_or = explode(' OR ', $clausel);
$where_break_or_c = count($where_break_or);
for($j = 0; $j < $where_break_or_c; $j++) {
if(!isset($where_break_or[$i])) {
continue;
}
$clausel2 = $where_break_or[$j];
if(isset($where_break_or[$j + 1]) AND preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $where_break_or[$j + 1]) != 1) {
$where_break_or[$j] = $where_break_or[$j]." OR ".$where_break_or[$j + 1];
$clausel2 = $where_break_or[$j];
unset($where_break_or[$j + 1]);
}
preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $clausel2, $matches);
var_dump($matches);
}
preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $clausel, $matches);
var_dump($matches);
}
preferences:
51.77 ms | 402 KiB | 5 Q