jonseg / crud-admin-generator

An open source tool to generate a complete backend from a MySql database.
http://crud-admin-generator.com/
MIT License
1.43k stars 441 forks source link

Enum in table cause error 500 #95

Open tomekit opened 8 years ago

tomekit commented 8 years ago

Generated code for enums is not a valid PHP.

E.g. generated:

$table_columns_type = array( 'varchar(6)', 'varchar(255)', 'varchar(8)', 'float(32,8)', 'int(4)', 'int(1)', 'enum('standard','noDecimals','realNoDecimals','dotThousandsCommaDecimal','apostropheThousandsDotDecimal','apostropheThousandsNoDecimals','spaceThousandsDotDecimal','spaceThousandsCommaDecimal','indian')', 'enum('before','after')', 'int(1)', 'int(1)', );

PHP Error:

[18-May-2016 09:51:48 UTC] PHP Parse error: syntax error, unexpected 'singleDrop' (T_STRING), expecting ')' in /data/poligon/admingenerator/web/controllers/_optionGroups/index.php on line 57 [18-May-2016 09:51:48 UTC] PHP Stack trace: [18-May-2016 09:51:48 UTC] PHP 1. {main}() /data/poligon/admingenerator/web/index.php:0 [18-May-2016 09:51:48 UTC] PHP 2. require_once() /data/poligon/admingenerator/web/index.php:13

mastacontrola commented 8 years ago

I'm seeing the exact same issue. The enum clauses, from the DB are passed back with single quotes wrapped around the individual values. The simple fix for this for now is to edit file src/console.php Line number 171. Change from: $TABLECOLUMNS_TYPE_ARRAY .= "\t\t" . "'". $table_column['type'] . "', \n"; TO: $TABLECOLUMNS_TYPE_ARRAY .= "\t\t" . "'". addslashes($table_column['type']) . "', \n";

ifigueroap commented 8 years ago

I just got the same issue +1

buttflattery commented 8 years ago

any update on this issue

pmalsenz commented 5 years ago

This error is still happening with enum. Any update ?

Error message (HTTP error 500): PHP Parse error: syntax error, unexpected 'ja' (T_STRING), expecting ')'

This is the first line with enum, some more are following: 'enum('ja','nein','extern','')',

pmalsenz commented 5 years ago

Forgot to re-run php console generate:admin, now the values for the enum fields are escaped with slashes. It's working !

Thanks @mastacontrola