Consistent function naming
shadowhand opened this issue · 3 comments
There is an odd mix of snake_case
(table_name
, etc) and camelCase
(fetchAll
, nameList
, etc) going on in the code.
Everything is camelCase except for table names. SQL is case-insensitive and most schemas are snake_case. The table name in $db->table_name()
is a shorthand for $db->table( 'table_name' )
and directly represents the schema, that's why it's in snake_case, too. It might be beneficial to have automatic camelCase to snake_case conversion; currently you could do that with a rewrite function, see the Database/setRewrite method.
When using Database::setRewrite
method to achieve this behavior i get strange error when back-referenced table names do not pass through this method and not converted to proper format. When you try to get back-referenced table, foreigh keys do not get converted.
P.S. It could be great if we could have some kind of settings to enable camelCase
behavior by default for all fields and tables.
P.P.S. @morris You are doing a great job to continue NotORM
style DB access in more modern way. Thank you!
Hey ilsenem, thanks for your kind words! Would you mind opening a separate issue describing how to reproduce the behavior you're experiencing with setRewrite? 🍻