Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:23:08+00:00 2026-06-02T01:23:08+00:00

RedBeanPHP uses class naming convention to tie a model to a table. I can’t

  • 0

RedBeanPHP uses class naming convention to tie a model to a table. I can’t abide by that naming convention since I have a project where table names aren’t set in stone. I need a way to connect a RedBean_SimpleModel to a table name without the naming convention – How do I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:23:10+00:00Added an answer on June 2, 2026 at 1:23 am

    OK, I found one solution while going through the API documentation. I can set my own “Model Formatter”, which just means that I can create a class that is given the responsibility of connecting the name of a table with the name of a class. My RedBean setup code now looks like this:

    # Redbean
    require('vendor/redbean/rb.php');
    
    R::setup("mysql:host=".MYSQL_HOST.";dbname=".MYSQL_DATABASE.";",
             MYSQL_USERNAME, MYSQL_PASSWORD);
    
    # Set custom model formatter
    class CustomRedBeanModelFormatter implements RedBean_IModelFormatter
    {
        public function formatModel($model)
        {
            switch($model)
            {
                case foo\bar\OmniDataManager::TABLE_DATA:
                    return 'foo\bar\OmniDataModel';
                case foo\bar\OmniDataManager::TABLE_GROUP:
                    return 'foo\bar\OmniDataGroupModel';
                default:
                    return false;
            }
        }
    }
    $customRedBeanModelFormatter = new CustomRedBeanModelFormatter();
    RedBean_ModelHelper::setModelFormatter($customRedBeanModelFormatter);
    

    It’s a bit of an ugly solution. I would much rather be able to do something like this:

    RedBean_ModelHelper::setModelForTable($modelName, $tableName);
    

    For that reason I will hold off on marking this as the correct answer for a while.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using readbeanphp as ORM for my php project. I'm trying to load a
I was wondering how I would go about checking to see if a table
I'm working on a small project (some mark tracking software for a school subject
Codeigniter has its own Models path, where models extend from CI_Model. I'm using RedBean
am trying to get a simple nested bean relationship - what am i missing?
// Includes rb.php here etc. $mail_type = array('gmail.com', 'yahoo.com', 'yandex.ru', 'hotmail.com', 'live.no'); for ($i
I'm connecting to MySQL with Redbean PHP and both date and date_deux come through
What is the best way to get PHP 5.3 up and running on CentOS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.