wordpress/wp-content/plugins/sqlite-integration/query_alter.class.php
/**
	 * Function to handle DROP PRIMARY KEY.
	 *
	 * @access private
	 * @param array of string $queries
	 * @return array of string
	 */
Function to handle DROP PRIMARY KEY.
@access private
@param array of string $queries
@return array of string
Function to handle DROP PRIMARY KEY . @access private @param array of string $queries @return array of string
private function handle_drop_primary_key($queries) {
		$tokenized_query = $queries;
		$temp_table      = 'temp_'.$tokenized_query['table_name'];
		$_wpdb = new PDODB();
		$query_obj = $_wpdb->get_results("SELECT sql FROM sqlite_master WHERE tbl_name='{$tokenized_query['table_name']}'");
		$_wpdb = null;
		for ($i = 0; $i < count($query_obj); $i++) {
			$index_queries[$i] = $query_obj[$i]->sql;
		}
		$table_query = array_shift($index_queries);
		$pattern1    = '/^\\s*PRIMARY\\s*KEY\\s*\(.*\)/im';
		$pattern2    = '/^\\s*.*(PRIMARY\\s*KEY\\s*(:?AUTOINCREMENT|))\\s*(?!\()/im';
		if (preg_match($pattern1, $table_query, $match)) {
			$table_query = str_replace($match[0], '', $table_query);
		} elseif (preg_match($pattern2, $table_query, $match)) {
			$table_query = str_replace($match[1], '', $table_query);
		}
		$table_query = str_replace($tokenized_query['table_name'], $temp_table, $table_query);
		$query[]     = $table_query;
		$query[]     = "INSERT INTO $temp_table SELECT * FROM {$tokenized_query['table_name']}";
		$query[]     = "DROP TABLE IF EXISTS {$tokenized_query['table_name']}";
		$query[]     = "ALTER TABLE $temp_table RENAME TO {$tokenized_query['table_name']}";
		foreach ($index_queries as $index) {
			$query[] = $index;
		}
		return $query;
	}
private function handle_drop_primary_key ( $ queries ) { $ tokenized_query = $ queries ; $ temp_table = 'temp_' . $ tokenized_query [ 'table_name' ] ; $ _wpdb = new PDODB ( ) ; $ query_obj = $ _wpdb -> get_results ( " SELECT sql FROM sqlite_master WHERE tbl_name=' { $ tokenized_query [ 'table_name' ] } ' " ) ; $ _wpdb = null ; for ( $ i = 0 ; $ i < count ( $ query_obj ) ; $ i ++ ) { $ index_queries [ $ i ] = $ query_obj [ $ i ] -> sql ; } $ table_query = array_shift ( $ index_queries ) ; $ pattern1 = '/^\\s*PRIMARY\\s*KEY\\s*\(.*\)/im' ; $ pattern2 = '/^\\s*.*(PRIMARY\\s*KEY\\s*(:?AUTOINCREMENT|))\\s*(?!\()/im' ; if ( preg_match ( $ pattern1 , $ table_query , $ match ) ) { $ table_query = str_replace ( $ match [ 0 ] , '' , $ table_query ) ; } elseif ( preg_match ( $ pattern2 , $ table_query , $ match ) ) { $ table_query = str_replace ( $ match [ 1 ] , '' , $ table_query ) ; } $ table_query = str_replace ( $ tokenized_query [ 'table_name' ] , $ temp_table , $ table_query ) ; $ query [ ] = $ table_query ; $ query [ ] = " INSERT INTO  $ temp_table  SELECT * FROM  { $ tokenized_query [ 'table_name' ] } " ; $ query [ ] = " DROP TABLE IF EXISTS  { $ tokenized_query [ 'table_name' ] } " ; $ query [ ] = " ALTER TABLE  $ temp_table  RENAME TO  { $ tokenized_query [ 'table_name' ] } " ; foreach ( $ index_queries as $ index ) { $ query [ ] = $ index ; } return $ query ; }
Function to handle DROP PRIMARY KEY.
Function to handle DROP PRIMARY KEY .