From 700bcf285e4a18c0d63a9ecd0511cf052f6fcd93 Mon Sep 17 00:00:00 2001 From: xevidos Date: Wed, 17 Apr 2019 12:11:32 -0400 Subject: [PATCH] Added innodb storage for longer key lengths, Added key size calculation. --- components/sql/class.sql.conversions.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/components/sql/class.sql.conversions.php b/components/sql/class.sql.conversions.php index 6b44f08..221f6a8 100644 --- a/components/sql/class.sql.conversions.php +++ b/components/sql/class.sql.conversions.php @@ -384,6 +384,15 @@ class sql_conversions { $id_open = $this->wraps["open"][$dbtype]; $fields_string = ""; $unique_string = ""; + $unique_length = 0; + + foreach( $attributes as $id => $attributes ) { + + if( in_array( "unique", $attributes ) ) { + + $unique_length++; + } + } foreach( $attributes as $id => $attributes ) { @@ -393,9 +402,10 @@ class sql_conversions { $unique_string = $this->specials["unique"][$dbtype] . ","; } - if( $dbtype == "mysql" && $fields[$id] == "text" ) { + if( $dbtype == "mysql" && $fields ) { - $fields_string .= "{$id_open}{$id}{$id_close}(1000),"; + $field_length = ( 3000 / $unique_length ); + $fields_string .= "{$id_open}{$id}{$id_close}($field_length),"; } else { $fields_string .= "{$id_open}{$id}{$id_close},"; @@ -408,7 +418,7 @@ class sql_conversions { $query .= $unique_string; $query = substr( $query, 0, -1 ); - $query .= ");"; + $query .= ") ENGINE=InnoDB;"; return( $query ); }