wordpress/wp-content/plugins/sqlite-integration/query_alter.class.php
/**
	 * Function to change the field definition to SQLite compatible data type.
	 *
	 * @access private
	 * @param string $col_name
	 * @param string $col_def
	 * @return string
	 */
Function to change the field definition to SQLite compatible data type.
Function to change the field definition to SQLite compatible data type .
private function convert_field_types($col_name, $col_def){
		$array_curtime = array('current_timestamp', 'current_time', 'current_date');
		$array_reptime = array("'0000-00-00 00:00:00'", "'0000-00-00 00:00:00'", "'0000-00-00'");
		$def_string    = str_replace('`', '', $col_def);
		foreach ($this->array_types as $o=>$r){
			$pattern = "/\\b$o\\s*(\([^\)]*\)*)?\\s*/ims";
			if (preg_match($pattern, $def_string)) {
				$def_string = preg_replace($pattern, "$r ", $def_string);
				break;
			}
		}
		$def_string = preg_replace('/unsigned/im', '', $def_string);
		$def_string = preg_replace('/auto_increment/im', 'PRIMARY KEY AUTOINCREMENT', $def_string);
		$def_string = str_ireplace($array_curtime, $array_reptime, $def_string);
		$pattern_enum = '/enum\((.*?)\)([^,\)]*)/ims';
		if (preg_match($pattern_enum, $col_def, $matches)) {
			$def_string = 'TEXT' . $matches[2] . ' CHECK (' . $col_name . ' IN (' . $matches[1] . '))';
		}
		return $def_string;
	}
private function convert_field_types ( $ col_name , $ col_def ) { $ array_curtime = array ( 'current_timestamp' , 'current_time' , 'current_date' ) ; $ array_reptime = array ( " '0000-00-00 00:00:00' " , " '0000-00-00 00:00:00' " , " '0000-00-00' " ) ; $ def_string = str_replace ( '`' , '' , $ col_def ) ; foreach ( $ this -> array_types as $ o => $ r ) { $ pattern = " / \\ b $ o \\ s*(\([^\)]*\)*)? \\ s*/ims " ; if ( preg_match ( $ pattern , $ def_string ) ) { $ def_string = preg_replace ( $ pattern , " $ r " , $ def_string ) ; break ; } } $ def_string = preg_replace ( '/unsigned/im' , '' , $ def_string ) ; $ def_string = preg_replace ( '/auto_increment/im' , 'PRIMARY KEY AUTOINCREMENT' , $ def_string ) ; $ def_string = str_ireplace ( $ array_curtime , $ array_reptime , $ def_string ) ; $ pattern_enum = '/enum\((.*?)\)([^,\)]*)/ims' ; if ( preg_match ( $ pattern_enum , $ col_def , $ matches ) ) { $ def_string = 'TEXT' . $ matches [ 2 ] . ' CHECK (' . $ col_name . ' IN (' . $ matches [ 1 ] . '))' ; } return $ def_string ; }
Function to change the field definition to SQLite compatible data type.
Function to change the field definition to SQLite compatible data type .
// when you use ALTER TABLE ADD, you can't use current_*. so we replace // colDef is enum