wordpress/wp-content/plugins/sqlite-integration/query.class.php
/**
	 * Method to handle ORDER BY FIELD() clause.
	 *
	 * When FIELD() function has column name to compare, we can't rewrite it with
	 * use defined functions. When this function detect column name in the argument,
	 * it creates another instance, does the query withuot ORDER BY clause and gives
	 * the result array sorted to the main instance.
	 *
	 * If FIELD() function doesn't have column name, it will use the user defined
	 * function. usort() function closure function to compare the items.
	 *
	 * @access private
	 */
Method to handle ORDER BY FIELD() clause.
When FIELD() function has column name to compare, we can't rewrite it with
use defined functions. When this function detect column name in the argument,
it creates another instance, does the query withuot ORDER BY clause and gives
the result array sorted to the main instance.

If FIELD() function doesn't have column name, it will use the user defined
function. usort() function closure function to compare the items.

@access private
Method to handle ORDER BY FIELD () clause . When FIELD () function has column name to compare we can ' t rewrite it with use defined functions . When this function detect column name in the argument it creates another instance does the query withuot ORDER BY clause and gives the result array sorted to the main instance . If FIELD () function doesn ' t have column name it will use the user defined function . usort () function closure function to compare the items . @access private
private function handle_orderby_field() {
		if (!$this->orderby_field) return;
		global $wpdb;
		$pattern = '/\\s+ORDER\\s+BY\\s+FIELD\\s*\(\\s*([^\)]+?)\\s*\)/i';
		if (preg_match($pattern, $this->_query, $match)) {
			global $flipped;
			$params   = explode(',', $match[1]);
			$params   = array_map('trim', $params);
			$tbl_col  = array_shift($params);
			$flipped  = array_flip($params);
			$tbl_name = substr($tbl_col, 0, strpos($tbl_col, '.'));
			$tbl_name = str_replace($wpdb->prefix, '', $tbl_name);
			if ($tbl_name && in_array($tbl_name, $wpdb->tables)) {
				$query = str_replace($match[0], '', $this->_query);
				$_wpdb = new PDODB();
				$results = $_wpdb->get_results($query);
				$_wpdb = null;
                usort($results, array($this, 'orderby_callback'));
			}
			$wpdb->dbh->pre_ordered_results = $results;
		}
	}
private function handle_orderby_field ( ) { if ( ! $ this -> orderby_field ) return ; global $ wpdb ; $ pattern = '/\\s+ORDER\\s+BY\\s+FIELD\\s*\(\\s*([^\)]+?)\\s*\)/i' ; if ( preg_match ( $ pattern , $ this -> _query , $ match ) ) { global $ flipped ; $ params = explode ( ',' , $ match [ 1 ] ) ; $ params = array_map ( 'trim' , $ params ) ; $ tbl_col = array_shift ( $ params ) ; $ flipped = array_flip ( $ params ) ; $ tbl_name = substr ( $ tbl_col , 0 , strpos ( $ tbl_col , '.' ) ) ; $ tbl_name = str_replace ( $ wpdb -> prefix , '' , $ tbl_name ) ; if ( $ tbl_name && in_array ( $ tbl_name , $ wpdb -> tables ) ) { $ query = str_replace ( $ match [ 0 ] , '' , $ this -> _query ) ; $ _wpdb = new PDODB ( ) ; $ results = $ _wpdb -> get_results ( $ query ) ; $ _wpdb = null ; usort ( $ results , array ( $ this , 'orderby_callback' ) ) ; } $ wpdb -> dbh -> pre_ordered_results = $ results ; } }
Method to handle ORDER BY FIELD() clause.
Method to handle ORDER BY FIELD () clause .
/* $compare = function($a, $b) { */ /* 	global $flipped; */ /* 	return $flipped[$a->ID] - $flipped[$b->ID]; */ /* }; */ /* usort($results, $compare); */