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

  • Home
  • SEARCH
  • 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 4109798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:50:53+00:00 2026-05-20T21:50:53+00:00

Working on a project with the Zend Framework, I am using Propel ORM with

  • 0

Working on a project with the Zend Framework, I am using Propel ORM with many related database objects. I am new to both, but I have the object models created and working. I am just trying to get my head around object access now.

I have a method for creating a new user, its working good and updates related rows (Not every related, but it’s a start). Now I want to present the ‘New’ user data to the system user (user creater). I get the username back and I now want to get the ‘UserLevel’ among a few other properties.

After user creation I call my findUserByUserName method, passing the new user’s username, I get back all in the Users table, but I also need properties from the ‘AgenciesAndUsers’ table that are related to that new user.

This is what I am trying, but it dosent’ seem to work, plus it don’t seem right anyway…I should be able to pass the ‘Users->’ into the AgenciesAndUsers to get the related properties for that user:

         $User = UsersQuery::create()->findOneByUserName($UserName);
         $UserId = $User->getUserId();

         $UserData = AgenciesAndUsersQuery::create()->findOneByUserId($UserId);

         $data = // merge the two objects

         return $data;

This is where I stopped, because I realized that if this works, I have to pass two objects back to my controller (or whatever called my method). Is there, wait…I know there is…so “How Do I” access the properties from related object? I know this is half..or maybe the whole…reason for using an ORM system anyway 🙂

I attempted to reverse what I did when creating my user, but I just can’t seem to do it. Plus it may be better to just pass the new user’s data back after creating the new user in that method, don’t I have a persistent object after creating the new User? But I’m gonna need a ‘findUserByUserName’ method among many more anyway.

Here is how I create my new user and it’s AgencyAndUser data too…

$user = new Users();
        $user->setActive($Active);
        $user->setCreatedAt($CreatedAt);
        $user->setEmailAddress($EmailAddress);
        $user->setEnabledInForms($EnabledInForms);
        $user->setFirstName($FirstName);
        $user->setInitialPassword($InitialPassword);
        $user->setLastName($LastName);
        $user->setModifiedAt($ModifiedAt);      
        $user->setPassword($UserPassword);
        $user->setPhoneNumber($PhoneNumber);
        $user->setTitle($Title);
        $user->setUserName($UserName);
        $user->setUserPasswordActive($UserPasswordActive);  

        $user->save();

        $AgnecyAndUser = new AgenciesAndUsers();
        $AgnecyAndUser->setAgencyId($AgencyId);
        $AgnecyAndUser->setUserLevel($UserLevel);

        // associate the $Users object with the current $AgnecyAndUser
        $AgnecyAndUser->setUsers($user);
        $AgnecyAndUser->save();

Edit: I just realized (after looking at my posted question), that I could probably ‘chain’ all those ‘User’ properties into on line instead of repeating the ‘$User’ over and over.

Turned out clean, straight from the Propel Manual…which BTW I have read over many sections too, just having ‘startup’ issues as a beginner/novice.

  • 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-20T21:50:54+00:00Added an answer on May 20, 2026 at 9:50 pm

    If you have your relationship set up correctly there should be accessors for the object:

    $user->getAgenciesAndUsers();

    There shouldnt be a reason to query the AgenciesAndUsers separately. In fact if you use a JOIN in your query you should only need to hit the DB once.

    Also if you havent gone to far with this i would rename everything to it is singular ie. AgencyAndUser (or more rightly UserAgency), and User.

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

Sidebar

Related Questions

I have just started working on a project and I am using zend framework
I am working on a project using zend framework, php, mysql on ubuntu. I
I started working on a project in the mid. We are using Zend Framework,
I'm working on a project that is currently using the Zend Framework 1.7.6, however
I am working on implementing Zend Framework within an existing project that has a
I am working on a project with zend framework and i need your advise
Hi I'm currently working on some php - zend framework project on my osx
I have a project that uses Zend Framework and Zend_Translate . I had to
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I am working a project that does not have a trunk / branches /

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.