Search code examples
phpormredbean

Is there a rule to the name a link bean table gets given in Redbean?


I have a few link bean tables that were built by Redbean - each was created as a result of the following type of code;

//generates tag_video table
$tags = R::findAll('tag');
$video = R::dispense('video');
$video->sharedTag = $tags;
R::store($video);

//generates image_tag table
$image = R::dispense('image');
$image->sharedTag = $tags;
R::store($image);

//generates document_tag table
$document = R::dispense('document');
$document->sharedTag = $tags;
R::store($document);

Most of my link bean tables are named image_tag, document_tag. But I also have tag_video, which is a problem. I would prefer video_tag.

I'd like to be able to predict the link bean table names because I want to use them in JOIN's for times when I query the database directly, rather than using the ORM.

Is there a rule? Is it alphabetic perhaps? Can I insist on the 'parent' object type coming first in the table name?


Solution

  • I have since discovered that the link tables are always named alphabetically.

    Here is the response from the developer.

    The tables are always named alphabetically. Unfortunately given the fact that RB strives to be zero-conf, it's not recommended to enforce a naming convention. RedBeanPHP allows you to change most of the schema policy rules but I recommend not to do this because it will break things and defeat the purpose of RB althoghether.