wordpress/wp-content/plugins/sqlite-integration/query_alter.class.php
/**
	 * Function to handle MODIFY COLUMN.
	 *
	 * @access private
	 * @param array of string $queries
	 * @return string|array of string
	 */
Function to handle MODIFY COLUMN.
@access private
@param array of string $queries
@return string|array of string
Function to handle MODIFY COLUMN . @access private @param array of string $queries @return string|array of string
private function handle_modify_command($queries) {
		$tokenized_query = $queries;
		$temp_table      = 'temp_'.$tokenized_query['table_name'];
		$column_def      = $this->convert_field_types($tokenized_query['column_name'], $tokenized_query['column_def']);
		$_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;
		}
		$create_query = array_shift($index_queries);
		if (stripos($create_query, $tokenized_query['column_name']) === false) {
			return 'SELECT 1=1';
		} elseif (preg_match("/{$tokenized_query['column_name']}\\s*{$column_def}\\s*[,)]/i", $create_query)) {
			return 'SELECT 1=1';
		}
		$create_query = preg_replace("/{$tokenized_query['table_name']}/i", $temp_table, $create_query);
		if (preg_match("/\\b{$tokenized_query['column_name']}\\s*.*(?=,)/ims", $create_query)) {
			$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=,)/ims", "{$tokenized_query['column_name']} {$column_def}", $create_query);
		} elseif (preg_match("/\\b{$tokenized_query['column_name']}\\s*.*(?=\))/ims", $create_query)) {
			$create_query = preg_replace("/\\b{$tokenized_query['column_name']}\\s*.*(?=\))/ims", "{$tokenized_query['column_name']} {$column_def}", $create_query);
		}
		$query[] = $create_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_modify_command ( $ queries ) { $ tokenized_query = $ queries ; $ temp_table = 'temp_' . $ tokenized_query [ 'table_name' ] ; $ column_def = $ this -> convert_field_types ( $ tokenized_query [ 'column_name' ] , $ tokenized_query [ 'column_def' ] ) ; $ _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 ; } $ create_query = array_shift ( $ index_queries ) ; if ( stripos ( $ create_query , $ tokenized_query [ 'column_name' ] ) === false ) { return 'SELECT 1=1' ; } elseif ( preg_match ( " / { $ tokenized_query [ 'column_name' ] } \\ s* { $ column_def } \\ s*[,)]/i " , $ create_query ) ) { return 'SELECT 1=1' ; } $ create_query = preg_replace ( " / { $ tokenized_query [ 'table_name' ] } /i " , $ temp_table , $ create_query ) ; if ( preg_match ( " / \\ b { $ tokenized_query [ 'column_name' ] } \\ s*.*(?=,)/ims " , $ create_query ) ) { $ create_query = preg_replace ( " / \\ b { $ tokenized_query [ 'column_name' ] } \\ s*.*(?=,)/ims " , " { $ tokenized_query [ 'column_name' ] } { $ column_def } " , $ create_query ) ; } elseif ( preg_match ( " / \\ b { $ tokenized_query [ 'column_name' ] } \\ s*.*(?=\))/ims " , $ create_query ) ) { $ create_query = preg_replace ( " / \\ b { $ tokenized_query [ 'column_name' ] } \\ s*.*(?=\))/ims " , " { $ tokenized_query [ 'column_name' ] } { $ column_def } " , $ create_query ) ; } $ query [ ] = $ create_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 MODIFY COLUMN.
Function to handle MODIFY COLUMN .