gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.31k stars 279 forks source link

Cant you create beans with _ in them? #802

Closed benzon closed 4 years ago

benzon commented 4 years ago

Hi tryed to fit a bean in to my permission system

users_roles thought i could use usersRoles, and that gives an error.

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught RedBeanPHP\\RedException: Invalid type: usersRoles in /var/www/vhosts/dev.benzon.pw/httpdocs/vendor/gabordemooij/redbean/RedBeanPHP/Util/DispenseHelper.php:77\nStack trace:\n#0 /var/www/vhosts/dev.benzon.pw/httpdocs/vendor/gabordemooij/redbean/RedBeanPHP/Util/DispenseHelper.php(151): RedBeanPHP\\Util\\DispenseHelper::checkType()\n#1 /var/www/vhosts/dev.benzon.pw/httpdocs/vendor/gabordemooij/redbean/RedBeanPHP/Facade.php(853): RedBeanPHP\\Util\\DispenseHelper::dispense()\n#2 /var/www/vhosts/dev.benzon.pw/httpdocs/includes/steamauth.php(58): RedBeanPHP\\Facade::dispense()\n#3 /var/www/vhosts/dev.benzon.pw/httpdocs/routes/login.php(4): require('/var/www/vhosts...')\n#4 /var/www/vhosts/dev.benzon.pw/httpdocs/public/index.php(41): {closure}()\n#5 {main}\n thrown in /var/www/vhosts/dev.benzon.pw/httpdocs/vendor/gabordemooij/redbean/RedBeanPHP/Util/DispenseHelper.php on line 77'

benzon commented 4 years ago

tryed users_roles to and it did not work either.

Lynesth commented 4 years ago

Hey,

It should be lowercase only, so userrole (or usersroles) should be what you want. Also you cannot use an underscore as those are use for association tables (role_user would be the table that link beans from the user table to the role table in a many-to-many relationship, maybe that's what you want ?).

https://www.redbeanphp.com/index.php?p=/crud#conventions