wordpress/wp-content/plugins/sqlite-integration/pdoengine.class.php
/**
	 * Method to convert SHOW INDEX query data to PHP object.
	 *
	 * It rewrites the result of SHOW INDEX to the Object compatible with MySQL
	 * added the WHERE clause manipulation (ver 1.3.1)
	 *
	 * @access private
	 */
Method to convert SHOW INDEX query data to PHP object.
It rewrites the result of SHOW INDEX to the Object compatible with MySQL
added the WHERE clause manipulation (ver 1.3.1)

@access private
Method to convert SHOW INDEX query data to PHP object . It rewrites the result of SHOW INDEX to the Object compatible with MySQL added the WHERE clause manipulation ( ver 1 . 3 . 1 ) @access private
private function convert_to_index_object() {
		$_results = array();
		$_columns = array(
			'Table'        => "",
			'Non_unique'   => "",
			'Key_name'     => "",
			'Seq_in_index' => "",
			'Column_name'  => "",
			'Collation'    => "",
			'Cardinality'  => "",
			'Sub_part'     => "",
			'Packed'       => "",
			'Null'         => "",
			'Index_type'   => "",
			'Comment'      => ""
		);
		if (count($this->_results) == 0) {
			echo $this->get_error_message();
		} else {
			foreach ($this->_results as $row) {
				if ($row->type == 'table' && !stripos($row->sql, 'primary'))
					continue;
				if ($row->type == 'index' && stripos($row->name, 'sqlite_autoindex') !== false)
					continue;
				switch ($row->type) {
					case 'table':
						$pattern1 = '/^\\s*PRIMARY.*\((.*)\)/im';
						$pattern2 = '/^\\s*(\\w+)?\\s*.*PRIMARY.*(?!\()/im';
						if (preg_match($pattern1, $row->sql, $match)) {
							$col_name = trim($match[1]);
							$_columns['Key_name']    = 'PRIMARY';
							$_columns['Non_unique']  = 0;
							$_columns['Column_name'] = $col_name;
						} elseif (preg_match($pattern2, $row->sql, $match)) {
							$col_name = trim($match[1]);
							$_columns['Key_name']    = 'PRIMARY';
							$_columns['Non_unique']  = 0;
							$_columns['Column_name'] = $col_name;
						}
						break;
					case 'index':
						if (stripos($row->sql, 'unique') !== false) {
							$_columns['Non_unique'] = 0;
						} else {
							$_columns['Non_unique'] = 1;
						}
						if (preg_match('/^.*\((.*)\)/i', $row->sql, $match)) {
							$col_name = str_replace("'", '', $match[1]);
							$_columns['Column_name'] = trim($col_name);
						}
						$_columns['Key_name'] = $row->name;
						break;
					default:
						break;
				}
				$_columns['Table']       = $row->tbl_name;
				$_columns['Collation']   = NULL;
				$_columns['Cardinality'] = 0;
				$_columns['Sub_part']    = NULL;
				$_columns['Packed']      = NULL;
				$_columns['Null']        = 'NO';
				$_columns['Index_type']  = 'BTREE';
				$_columns['Comment']     = '';
				$_results[]              = new ObjectArray($_columns);
			}
			if (stripos($this->queries[0], 'WHERE') !== false) {
				preg_match('/WHERE\\s*(.*)$/im', $this->queries[0], $match);
				list($key, $value) = explode('=', $match[1]);
				$key = trim($key);
				$value = preg_replace("/[\';]/", '', $value);
				$value = trim($value);
				foreach ($_results as $result) {
					if (stripos($value, $result->$key) !== false) {
						unset($_results);
						$_results[] = $result;
						break;
					}
				}
			}
		}
		$this->results = $_results;
	}
private function convert_to_index_object ( ) { $ _results = array ( ) ; $ _columns = array ( 'Table' => " " , 'Non_unique' => " " , 'Key_name' => " " , 'Seq_in_index' => " " , 'Column_name' => " " , 'Collation' => " " , 'Cardinality' => " " , 'Sub_part' => " " , 'Packed' => " " , 'Null' => " " , 'Index_type' => " " , 'Comment' => " " ) ; if ( count ( $ this -> _results ) == 0 ) { echo $ this -> get_error_message ( ) ; } else { foreach ( $ this -> _results as $ row ) { if ( $ row -> type == 'table' && ! stripos ( $ row -> sql , 'primary' ) ) continue ; if ( $ row -> type == 'index' && stripos ( $ row -> name , 'sqlite_autoindex' ) !== false ) continue ; switch ( $ row -> type ) { case 'table' : $ pattern1 = '/^\\s*PRIMARY.*\((.*)\)/im' ; $ pattern2 = '/^\\s*(\\w+)?\\s*.*PRIMARY.*(?!\()/im' ; if ( preg_match ( $ pattern1 , $ row -> sql , $ match ) ) { $ col_name = trim ( $ match [ 1 ] ) ; $ _columns [ 'Key_name' ] = 'PRIMARY' ; $ _columns [ 'Non_unique' ] = 0 ; $ _columns [ 'Column_name' ] = $ col_name ; } elseif ( preg_match ( $ pattern2 , $ row -> sql , $ match ) ) { $ col_name = trim ( $ match [ 1 ] ) ; $ _columns [ 'Key_name' ] = 'PRIMARY' ; $ _columns [ 'Non_unique' ] = 0 ; $ _columns [ 'Column_name' ] = $ col_name ; } break ; case 'index' : if ( stripos ( $ row -> sql , 'unique' ) !== false ) { $ _columns [ 'Non_unique' ] = 0 ; } else { $ _columns [ 'Non_unique' ] = 1 ; } if ( preg_match ( '/^.*\((.*)\)/i' , $ row -> sql , $ match ) ) { $ col_name = str_replace ( " ' " , '' , $ match [ 1 ] ) ; $ _columns [ 'Column_name' ] = trim ( $ col_name ) ; } $ _columns [ 'Key_name' ] = $ row -> name ; break ; default : break ; } $ _columns [ 'Table' ] = $ row -> tbl_name ; $ _columns [ 'Collation' ] = NULL ; $ _columns [ 'Cardinality' ] = 0 ; $ _columns [ 'Sub_part' ] = NULL ; $ _columns [ 'Packed' ] = NULL ; $ _columns [ 'Null' ] = 'NO' ; $ _columns [ 'Index_type' ] = 'BTREE' ; $ _columns [ 'Comment' ] = '' ; $ _results [ ] = new ObjectArray ( $ _columns ) ; } if ( stripos ( $ this -> queries [ 0 ] , 'WHERE' ) !== false ) { preg_match ( '/WHERE\\s*(.*)$/im' , $ this -> queries [ 0 ] , $ match ) ; list ( $ key , $ value ) = explode ( '=' , $ match [ 1 ] ) ; $ key = trim ( $ key ) ; $ value = preg_replace ( " /[\';]/ " , '' , $ value ) ; $ value = trim ( $ value ) ; foreach ( $ _results as $ result ) { if ( stripos ( $ value , $ result -> $ key ) !== false ) { unset ( $ _results ) ; $ _results [ ] = $ result ; break ; } } } } $ this -> results = $ _results ; }
Method to convert SHOW INDEX query data to PHP object.
Method to convert SHOW INDEX query data to PHP object .
// unique -> 0, not unique -> 1 // the name of the index // column sequence number in the index. begins at 1 //A(scend) or NULL // set to NULL // How to pack key or else NULL // If column contains null, YES. If not, NO. // BTREE, FULLTEXT, HASH, RTREE