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 7825617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:05:01+00:00 2026-06-02T09:05:01+00:00

I have 3 database tables like rooms , room_type and room_status . Here is

  • 0

I have 3 database tables like rooms, room_type and room_status. Here is the tables` structure

rooms

room_id, room_number, room_type_id, room_status_id

room_type

room_type_id, room_type_name, room_type_desc

room_status

room_status_id, room_status_name, room_status_desc

So, Actually based on this tables need to create form to add new room. I already has created rooms controller and model.

My thought is to create form based on the rooms table and create another two controller for room_type and for room status. After that get data from room_type and room_status and pass it to room form where i can create select element using this data.

Can you advice how can I achieve better solution. I am not that sure that this is good solution.

[EDIT]

`$status = $this->createElement(‘select’, ‘status’);

    $status->setLabel("Select a status:");

    $status->addMultiOption('Active', 'active');

    $status->addMultiOption('Suspended', 'suspended');

    $this->addElement($status);`

As you can see here addMultiOptionis static, how to make it dynamic from the database? I hope I could explain you my idea?

  • 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-02T09:05:04+00:00Added an answer on June 2, 2026 at 9:05 am

    If I understand what you are trying to do, and I’m not sure I do. Setting Type and Status via a form would work in certain situations.
    First thing you might want to do would be to add a room_status_id to your room table, so you can track current status.

    I’m imagining your context is a hotel or convention center type setting. In this context the room type will likely not change frequently, but the status may change several times a day.
    So doing a form in like an admin console to setup the room and make initial type and status designations and the occasional change would be appropriate. For day to day operations you might want to include automatic status changes in your various controller actions.

    Some psuedo code for example:

    initiate room (admin): set room_type, set room_status;
    
    reserve room: set room_status: reserved;
    room in use: set room_status: in use;
    room vacant: if (room != clean) {
        set room_status: not clean
    } else {
        set room_status: clean
    }
    
    room being remodeled(admin)
    if (room_type === change) {
      set type: new room_type;
    } else {
      don't change room_type;
    }
    if (inRemodel === true) {
      set room_status: unavailable;
    }
    

    you probably don’t need a controller for room_type and room_status as this info is unlikely to be changed or manipulated a lot.
    room_type and room_status seem like they will be the kind of data that get set initially and then rarely change values. If that is the case the model would be the place to access these values and then just pass them where needed.

    I hope I haven’t missed the point completely.

    [EDIT]
    You asked how to display the names of room_type and room_status in your comment. You’d use a join:

    //make a dbTable model for each table
    //in your Application_Model_DbTable_Room, built a method similar to this to join the tables
    public function fetchRoomData() {
            //setIntegrityCheck to false to allow joins
            $select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                    ->setIntegrityCheck(FALSE);
            //performs join aliasing table room_type to t
            $select->join(array('t' => 'room_type'), 't.room_type_id = room.room_type_id');
            ////performs join aliasing table room_status to s
            $select->join(array('s' => 'room_status'), 's.room_status_id = room.room_status_id');
    
            $result = $this->fetchAll($select);
    
            return $result;
        }
    

    [EDIT]
    To display a select form element based on a db table:

    $bidlocation = new Zend_Form_Element_Select('room_type');
            $bidlocation->setLabel('Room Type: ');
    
            $b = new Application_Model_DbTable_RoomType();
            $a = $b->fetchAll();
    
            foreach ($a as $c) {
                //applies caps to first letter of each word
                $d = ucwords($c['room_type_name']);
                $bidlocation->addMultiOption($c['room_type_id'], $d);  
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in my database that look like that: Customer: C_ID city
I have a mysql database with a table structure like below : Table Name
I have 2 database tables that looks like this Subscriptions table member_id active 5
I have a SQL database with two tables like this: Users Id (PK) Name
I have a simple SQL Server 2008 database with two tables like this: TableA:
I have a set of database tables named like: site_1_details site_2_details site_3_details ... site_420_details
I have four Database Tables like these: Book ID_Book |ID_Company|Description BookExtension ID_BookExtension | ID_Book|
i have in the database typical tables like user, usergroup, and they have relations.
I have several related database tables and I would like to treat their rows
I have a legacy database with 3 tables like this: (source: bilder-hochladen.net ) The

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.