wordpress/wp-content/plugins/sqlite-integration/query.class.php
/**
	 * Method to parse query string and determine which operation is needed.
	 *
	 * Remove backticks and change true/false values into 1/0. And determines
	 * if rewriting CALC_FOUND_ROWS or ON DUPLICATE KEY UPDATE etc is needed.
	 *
	 * @access private
	 */
Method to parse query string and determine which operation is needed.
Remove backticks and change true/false values into 1/0.

@access private
Method to parse query string and determine which operation is needed . Remove backticks and change true / false values into 1 / 0 . @access private
private function parse_query() {
		$tokens = preg_split("/(\\\'|''|')/s", $this->_query, -1, PREG_SPLIT_DELIM_CAPTURE);
		$literal = false;
		$query_string = '';
		foreach ($tokens as $token) {
			if ($token == "'") {
				if ($literal) {
					$literal = false;
				} else {
					$literal = true;
				}
			} else {
				if ($literal === false) {
					if (strpos($token, '`') !== false) {
						$token = str_replace('`', '', $token);
					}
					if (preg_match('/\\bTRUE\\b/i', $token)) {
					  $token = str_ireplace('TRUE', '1', $token);
					}
					if (preg_match('/\\bFALSE\\b/i', $token)) {
					  $token = str_ireplace('FALSE', '0', $token);
					}
					if (stripos($token, 'SQL_CALC_FOUND_ROWS') !== false) {
						$this->rewrite_calc_found = true;
					}
					if (stripos($token, 'ON DUPLICATE KEY UPDATE') !== false) {
						$this->rewrite_duplicate_key = true;
					}
					if (stripos($token, 'USE INDEX') !== false) {
						$this->rewrite_index_hint = true;
					}
					if (stripos($token, 'IGNORE INDEX') !== false) {
						$this->rewrite_index_hint = true;
					}
					if (stripos($token, 'FORCE INDEX') !== false) {
						$this->rewrite_index_hint = true;
					}
					if (stripos($token, 'BETWEEN') !== false) {
						$this->rewrite_between = true;
						$this->num_of_rewrite_between++;
					}
					if (stripos($token, 'ORDER BY FIELD') !== false) {
						$this->orderby_field = true;
					}
				}
			}
			$query_string .= $token;
		}
		$this->_query = $query_string;
	}
private function parse_query ( ) { $ tokens = preg_split ( " /( \\ \'|''|')/s " , $ this -> _query , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ literal = false ; $ query_string = '' ; foreach ( $ tokens as $ token ) { if ( $ token == " ' " ) { if ( $ literal ) { $ literal = false ; } else { $ literal = true ; } } else { if ( $ literal === false ) { if ( strpos ( $ token , '`' ) !== false ) { $ token = str_replace ( '`' , '' , $ token ) ; } if ( preg_match ( '/\\bTRUE\\b/i' , $ token ) ) { $ token = str_ireplace ( 'TRUE' , '1' , $ token ) ; } if ( preg_match ( '/\\bFALSE\\b/i' , $ token ) ) { $ token = str_ireplace ( 'FALSE' , '0' , $ token ) ; } if ( stripos ( $ token , 'SQL_CALC_FOUND_ROWS' ) !== false ) { $ this -> rewrite_calc_found = true ; } if ( stripos ( $ token , 'ON DUPLICATE KEY UPDATE' ) !== false ) { $ this -> rewrite_duplicate_key = true ; } if ( stripos ( $ token , 'USE INDEX' ) !== false ) { $ this -> rewrite_index_hint = true ; } if ( stripos ( $ token , 'IGNORE INDEX' ) !== false ) { $ this -> rewrite_index_hint = true ; } if ( stripos ( $ token , 'FORCE INDEX' ) !== false ) { $ this -> rewrite_index_hint = true ; } if ( stripos ( $ token , 'BETWEEN' ) !== false ) { $ this -> rewrite_between = true ; $ this -> num_of_rewrite_between ++ ; } if ( stripos ( $ token , 'ORDER BY FIELD' ) !== false ) { $ this -> orderby_field = true ; } } } $ query_string .= $ token ; } $ this -> _query = $ query_string ; }
Method to parse query string and determine which operation is needed.
Method to parse query string and determine which operation is needed .