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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:09:18+00:00 2026-05-15T05:09:18+00:00

I need to access my session and based on the session property I need

  • 0

I need to access my session and based on the session property I need to grab stuff from the database to use as options in my dropdown.

$_SESSION is:

[sess_name] => Array(
   [properties] => Array(
      1=> Hotel A,
      2=> Hotel B
   ),
   [selected] => 1
)

I need to grab Hotel A from selected, and then access all accounts under Hotel A from the database:

id  title                       hotel_id
------------------------------
1    Hotel A Twitter Account     1
2    Hotel B Facebook Account    2
3    Hotel A Facebook Account    1

I need ids 1 and 3 because my hotel_id is 1 in the context of:

$this->addElement(  'select', 'account', array(
  'multioptions' => $NEED_IT_HERE
));

Here’s my query / session grabbing code:

$cs = new Zend_Session_Namespace( SESS_NAME );
$model = new Model_DbTable_Social;
$s = "
    SELECT social_accounts.*
    FROM social_accounts
    LEFT JOIN social_media_outlets ON social_media_outlets.id = social_accounts.property
    WHERE social_accounts.property=".(int)$cs->selectedclient;

I have this code in my form page, but I need to move it into my model now.

  • 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-05-15T05:09:19+00:00Added an answer on May 15, 2026 at 5:09 am

    So where is your problem?

    Make a proper query on your database to get those accounts.

    Make a proper array from the result. ( id => Title )

    You can set options on already existing element:

    $element = $form->getElement('account');
    $element->setMultiOption( $option_array );
    

    You can create a method in your form class which would accept DB obj, Session obj and perform the actions needed to load and set those options.


    model, which is in application/modules/foo/models/DbTable/Social, the model class name is Model_DbTable_Social and the module is foo. Throws Fatal error:

    Your db-table class probably should be named:

    Foo_Model_DbTable_Social
    

    And application.ini should contain:

    resources.modules[] = 
    ; (It is autoloader for modules)
    

    Class ‘Model_DbTable_Social’ when I try to invoke it in my form. Or is that way which you mention easier?

    It is a good practice to ask for those resources in __construct like chelmertz said. Here is a nice talk on related subject:
    http://www.youtube.com/watch?v=-FRm3VPhseI

    You might want to read my question on “where to connect forms to models”:
    zend-framework doctrine, and mvc pattern: what kind of layer should connect data between models and forms?
    Not too many solutions though

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

Sidebar

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.