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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:06:47+00:00 2026-06-06T19:06:47+00:00

My schema is quite simple- Each user has an id and name. There are

  • 0

My schema is quite simple-
Each user has an id and name.
There are jobs which belong to a user. Actual schema-

CREATE TABLE `users` (
   id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,  
  `name` varchar(20) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `jobs` (
   id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT UNSIGNED ,
  `type` int,  
  FOREIGN KEY (user_id) references  users(id) 
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

My JobsController looks like this-

<?php
class JobsController extends AppController {
    public $scaffold;
    public $name = 'Job';

    public $belongsTo = array(
        'User' => array(
            'className'    => 'User',
            'foreignKey'   => 'user_id'
        )
    );

}

And UsersController as-

<?php
class UsersController extends AppController {
    public $scaffold;
    public $name = 'User';


    public $hasMany = array(
        'Job' => array(
            'className'     => 'Job',
            'foreignKey'    => 'user_id'
        )
    );
}

Problem:

When I visit http://hostname/Jobs/add I can see a drop-down for user but its empty.
I’ve created few users which I can see from http://hostname/Users/

Why is drop-down empty? I am able to add jobs but when I view them, user field is shown empty.

  • 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-06T19:06:49+00:00Added an answer on June 6, 2026 at 7:06 pm

    Associations belong in the Model, not the controller.

    In app/Model/User.php:

    class User extends AppModel {
        public $name = 'User';
        public $hasMany = array('Job');
    }
    

    In app/Model/Job.php

    class Job extends AppModel {
        public $name = 'Job';
        public $belongsTo = array('User');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple XML parser where each different XML schema has
Schema: Users ID Name Password Address ID Street UserID Both tables have an ID
XML Schema specifies occurrence indicators (maxOccurrence, minOccurrence). Is there a best practice in which
So here's my schema (give or take): cmds.Add(@CREATE TABLE [Services] ([Id] INTEGER PRIMARY KEY,
I'm creating a data-entry application where users are allowed to create the entry schema.
I am still quite confused about NHibernate schema export and creation. What I want
My schema is as follows: The airports table holds airport names. It's primary key
Suppose I have some schema: <xsd:schema ...> <xsd:element name=foo> <xsd:complexType> <xsd:sequence> <xsd:element name=fooElement type=xs:string
My question is quite simple. I'm adding a header to a SOAP request that
I have a quite simple activity like this : public class SurvivalActivity extends Activity

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.