Вводит разделители в истинное положение (PHP)?

Это функция в моем классе. Я понятия не имею, для наложения $ newConditions с (ИЛИ) (И).

У кого-нибудь есть идея?

// @GETSSQ = Get Secured Select Query
function getSSQ($query) {
$conDelimiters = array(' OR ',' AND '); // Condition Delimiters
$fivaDelimiters = array('LIKE','<=>','<>','=>','<=','!=','=','<','>'); // Field & Value delimiters {Operators}
$conditions = preg_split("/(".implode('|',$conDelimiters).")/", $query);
$newConditions = array();
$operator = array("operator" => null);

foreach ($conditions as $idx => $cond) {
$operator["index"] = strlen($cond);
foreach ($fivaDelimiters as $sym) {
$pos = strpos($cond,$sym);
if ($pos === false)
continue;
else {
if ($pos < $operator['index']) {
$operator['index'] = $pos;
$operator['operator'] = $sym;
}
}
}
// Operatör bölme işlemine devam et...
$parts = array();
if ($operator['operator'] === null) {
$error = array(
"error" => "Koşullar arası yazım hatası tespit edildi. [".$this->options['connectionType'].":".$query."]",
"code" => "008");
$this->showError($error);
continue;
} else {
$condParts = explode($operator['operator'],$cond);
foreach ($condParts as $idx => $val) {
$condParts[$idx] = trim($val);
}
$parts['field'] = $this->__getSSQ_editFields($condParts[0]);
$parts['operator'] = $this->__getSSQ_editOperators($operator['operator']);
$newValue = $condParts[1];
if (count($condParts) > 2) { // If condition value has an operator character set
unset($condParts[0]);
$newValue = implode($operator['operator'],$condParts);
}
if (preg_match("/^['|\"](.*?)['|\"]$/", $newValue)) { // If value has {'} or {"} character begin & end , remove it
$newValue = substr($newValue, 1, (strlen($newValue)-2));
}
$newValue = $this->__getSSQ_editValues($newValue);
$parts['value'] = $newValue;
} #ENDIF OPERATOR === NULL
$newConditions[] = $parts['field'].' '.$parts['operator'].' '.$parts['value'];

} #END FOREACH CONDITIONS
var_dump($newConditions);


}

Например, моя функция:

$condition = "id=5 AND parentCategory=2 AND firstName LIKE 'B%' AND usingMobile = 'true'";
$db = new XXClass();
$db->getSSQ($condition);

Этот вывод =>

array (size=4)
0 => string 'id = '5'' (length=8)
1 => string 'parentCategory = '2'' (length=20)
2 => string 'firstName LIKE 'B%'' (length=19)
3 => string 'usingMobile = 'true'' (length=20)

Я могу добраться до полей, операторов, значений с помощью функций __getSSQ_editXXXXX

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector