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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:43:21+00:00 2026-06-15T23:43:21+00:00

CREATE TABLE IF NOT EXISTS `employees` ( `employees_id` int(11) NOT NULL AUTO_INCREMENT, `employees_firstname` varchar(100)

  • 0
CREATE TABLE IF NOT EXISTS `employees` (
  `employees_id` int(11) NOT NULL AUTO_INCREMENT,
  `employees_firstname` varchar(100) DEFAULT NULL,
  `employees_middlename` varchar(45) DEFAULT NULL,
  `employees_lastname` varchar(100) DEFAULT NULL,
  `employee_gender` enum('M','F') NOT NULL,
  `employees_dob` date DEFAULT NULL,
  `employees_emailaddress` varchar(255) DEFAULT NULL,
  `employees_password` varchar(45) DEFAULT NULL,
  `employees_datejoined` date DEFAULT NULL,
  `employees_code` varchar(45) DEFAULT NULL,
  `employees_status` tinyint(1) DEFAULT '1',
  `employees_mobile` varchar(15) DEFAULT NULL,
  `employees_designation` int(11) DEFAULT NULL,
  `employees_bussiness_account` int(11) DEFAULT NULL,
  `employees_image` varchar(255) DEFAULT NULL,
  `employees_supervisers_id` int(11) DEFAULT NULL,
  `employees_work_location_id` int(11) DEFAULT NULL,
  `employees_date_added` datetime DEFAULT NULL,
  PRIMARY KEY (`employees_id`),
  UNIQUE KEY `employees_code_UNIQUE` (`employees_code`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

--
-- Dumping data for table `employees`
--

INSERT INTO `employees` (`employees_id`, `employees_firstname`, `employees_middlename`, `employees_lastname`, `employee_gender`, `employees_dob`, `employees_emailaddress`, `employees_password`, `employees_datejoined`, `employees_code`, `employees_status`, `employees_mobile`, `employees_designation`, `employees_bussiness_account`, `employees_image`, `employees_supervisers_id`, `employees_work_location_id`, `employees_date_added`) VALUES
(16, 'Aneesh', 'C', 'S', 'M', '2012-11-05', 'aneesh.cs@calpinetech.com', '7106499a88fd79197ddbff61829993c9', '2010-12-07', 'cas927', 1, '9876543210', 1, 1, 'Betson.JPG', 0, 1, '2012-11-27 00:00:00'),
(17, 'Betson', 'T', 'Thomas', 'M', '2012-11-05', 'betson@calpinetech.com', '7106499a88fd79197ddbff61829993c9', '2008-12-06', 'cas450', 1, '9876543210', 6, 1, NULL, 16, 1, '2012-11-27 00:00:00'),
(18, 'test', 'test', 'test', 'M', '2012-11-12', 'test@calpinetech.com', '7106499a88fd79197ddbff61829993c9', '2012-11-06', 'cas999', 1, '9876543210', 1, 1, NULL, 16, 1, '2012-11-27 00:00:00'),
(19, 'asdsa', 'asdsad', 'asdsad', 'M', '2012-12-03', 'test@calpinetech.com', 'd8578edf8458ce06fbc5bb76a58c5ca4', '2012-12-24', 'ca0999', 1, '9876543210', 1, 1, NULL, 17, 1, '2012-12-04 00:00:00');

This is my table. Here employees_supervisers_id is the employees_id. How can we get the recursive data through cakephp?

  • 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-15T23:43:22+00:00Added an answer on June 15, 2026 at 11:43 pm

    I think that you are trying to create parent/child relationships between records in the same table. If that is what you are asking, you can create those relationships in the Employee model like this:

    public $belongsTo = array(
        'Supervisor' => array(
            'className' => 'Employee',
            'foreignKey' => 'employee_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
    );
    
    public $hasMany = array(
        'Underlings' => array(
            'className' => 'Employee',
            'foreignKey' => 'employees_supervisers_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        ),
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(50)
CREATE TABLE IF NOT EXISTS `Channels` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30)
SQL STRUCTURE CREATE TABLE IF NOT EXISTS `map` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Tables: CREATE TABLE IF NOT EXISTS `posts` ( `post_n` int(10) NOT NULL auto_increment, `id`
table: graduate_applicants CREATE TABLE IF NOT EXISTS `graduate_applicants` ( `grat_id` int(10) NOT NULL auto_increment,
CREATE TABLE IF NOT EXISTS `questions` ( `question_id` int(11) NOT NULL AUTO_INCREMENT, `createddate` timestamp
Table Structure CREATE TABLE IF NOT EXISTS `blogs` ( `id` int(11) NOT NULL auto_increment,
CREATE TABLE IF NOT EXISTS `foo` ( `foo_id` INT NOT NULL AUTO_INCREMENT , `unique`
Table definition: CREATE TABLE IF NOT EXISTS `submenu_cat` ( `id` int(11) NOT NULL AUTO_INCREMENT,
CREATE TABLE IF NOT EXISTS `carslibrary` ( `CarID` int(10) unsigned NOT NULL AUTO_INCREMENT, `CarName`

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.