/** * extract all query properties * * @access private * @ param string $query query */ function explodeQuery($query = '') { if ($query == '') { $query = $this->query; } $query = $this->formattedQuery = ereg_replace("''", '#%£Q£%#', $query); $tabQuote = strpos_all($query, "'"); $inString = false; $this->tabString = array(); $stringNumber = 0; if (is_array($tabQuote)) { while (list($key, $posQuote) = each($tabQuote)) { if (!$inString) { $start = $posQuote; $stringNumber++; $inString = true; } else { $end = $posQuote; $subQuery = substr($query, $start, $end - $start + 1); $this->tabString[$stringNumber] = ereg_replace('#%£Q£%#', "''", $subQuery); $this->formattedQuery = str_replace($subQuery, '#%£' . $stringNumber . '£%#', $this->formattedQuery); $inString = false; } } } $this->formattedQuery = str_replace("\t", '', $this->formattedQuery); $tabExplodedQuery = split('[[:space:]]+', $this->formattedQuery); $tabOut = array(); foreach ($tabExplodedQuery as $once) { if (eregi('[' . preg_quote($GLOBALS['SQLpunct']) . ']', $once)) { $once = preg_replace('/[' . preg_quote($GLOBALS['SQLpunct']) . ']/', ' $0 ', $once); $tempTab = explode(" ", $once); $tabOut = array_merge($tabOut, $tempTab); } else { $tabOut[] = $once; } } $this->explodedQuery = $tabOut; return; }
/** * Return a tab with all position of a caractere * * @param string $string haystack string * @param char $seperation needle string to find */ function strpos_all($string, $separator) { static $tabPos = array(); $pos = strpos($string, $separator); if ((string) $pos != "") { if (count($tabPos) >= 1) { $addPrec = $tabPos[count($tabPos) - 1] + 1; } else { $addPrec = 0; } array_push($tabPos, $pos + $addPrec); $substring = substr($string, $pos + 1, strlen($string) - ($pos + 1)); strpos_all($substring, $separator); } return $tabPos; }