Fixed locate mysql function and varchar definition in sql library.

This commit is contained in:
xevidos 2019-04-10 20:34:06 -04:00
parent 22a5ddc115
commit 373c281111

View File

@ -20,7 +20,7 @@ class sql_conversions {
"find" => array( "find" => array(
"mysql" => "LOCATE( %string%, %substring% )", "mysql" => "LOCATE( %substring%, %string% )",
"pgsql" => "POSITION( %substring% in %string% )", "pgsql" => "POSITION( %substring% in %string% )",
"sqlite" => "INSTR( %string%, %substring% )", "sqlite" => "INSTR( %string%, %substring% )",
), ),
@ -103,7 +103,7 @@ class sql_conversions {
"string" => array( "string" => array(
"mysql" => "VARCHAR", "mysql" => "VARCHAR(255)",
"pgsql" => "VARCHAR", "pgsql" => "VARCHAR",
"sqlite" => "VARCHAR", "sqlite" => "VARCHAR",
), ),
@ -393,9 +393,15 @@ class sql_conversions {
$unique_string = $this->specials["unique"][$dbtype] . ","; $unique_string = $this->specials["unique"][$dbtype] . ",";
} }
if( $dbtype == "mysql" && $fields[$id] == "text" ) {
$fields_string .= "{$id_open}{$id}{$id_close}(1024),";
} else {
$fields_string .= "{$id_open}{$id}{$id_close},"; $fields_string .= "{$id_open}{$id}{$id_close},";
} }
} }
}
$unique_string = str_replace( "%constraint_name%", strtolower( preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ').']#', '', $fields_string ) ), $unique_string ); $unique_string = str_replace( "%constraint_name%", strtolower( preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ').']#', '', $fields_string ) ), $unique_string );
$unique_string = str_replace( "%field_names%", substr( $fields_string, 0, -1 ), $unique_string ); $unique_string = str_replace( "%field_names%", substr( $fields_string, 0, -1 ), $unique_string );
@ -412,7 +418,7 @@ class sql_conversions {
foreach( $tables as $table_name => $table_data ) { foreach( $tables as $table_name => $table_data ) {
$query .= $this->table( $table_name, $table_data["fields"], $table_data["attributes"] ); $query .= $this->table( $table_name, $table_data["fields"], $table_data["attributes"] ) . PHP_EOL;
} }
return( $query ); return( $query );
} }