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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:51:44+00:00 2026-06-13T10:51:44+00:00

My DB Structure: CREATE TABLE IF NOT EXISTS `pos` ( `id` int(11) NOT NULL

  • 0

My DB Structure:

CREATE TABLE IF NOT EXISTS `pos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `alias` varchar(255) NOT NULL,
  `model` varchar(255) NOT NULL,
  `foreign_key` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `alias` (`alias`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `psos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `po_id` int(11) NOT NULL,
  `lft` int(11) NOT NULL DEFAULT '0',
  `rght` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

My Models Structure:

class Po extends Model {
    public $name = 'Po';
    public $useTable = 'pos';
    public $cacheQueries = false;
    public $hasMany = array(
        'Pso' => array(
            'className' => 'Pso',
            'foreignKey' => 'po_id',
            'dependent' => true,
        ),
        'Puso' => array(
            'className' => 'Puso',
            'foreignKey' => 'po_id',
            'dependent' => true,
        ),
    );
}

class Pso extends Model {
    public $name = 'Pso';
    public $useTable = 'psos';
    public $cacheQueries = false;
    public $actsAs = array(
        'Tree',
    );

    public $belongsTo = array(
        'Parent' => array(
            'className' => 'Pso',
            'foreignKey' => 'parent_id',
        ),
        'Po' => array(
            'className' => 'Po',
            'foreignKey' => 'po_id',
        ),
    );

    public $hasMany = array(
        'Children' => array(
            'className' => 'Pso',
            'foreignKey' => 'parent_id',
        ),
    );

}

My Saving Associated test code:

$Po->saveAssociated(array(
    'Po' => array(
        'alias' => 'teste'.uniqid(),
    ),
    'Pso' => array(
        'parent_id' => 2,
    ),
));

Resulting PSO saved Row:

array('id'=>4,'parent_id'=>0,'po_id'=>4,'lft'=>7,'rght'=>8)

Expected PSO saved Row:

array('id'=>4,'parent_id'=>2,'po_id'=>4,'lft'=>7,'rght'=>8)
  • 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-13T10:51:45+00:00Added an answer on June 13, 2026 at 10:51 am

    Resolved like this:

    $Po->saveAssociated(array(
        'Po' => array(
            'alias' => 'teste'.uniqid(),
        ),
        'Pso' => array(
            'parent_id' => array(
                'parent_id' => 2,
            ),
        ),
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL STRUCTURE CREATE TABLE IF NOT EXISTS `map` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Table Structure CREATE TABLE IF NOT EXISTS `blogs` ( `id` int(11) NOT NULL auto_increment,
Simplified Table structure: CREATE TABLE IF NOT EXISTS `hpa` ( `id` bigint(15) NOT NULL
My table structure is below: CREATE TABLE [ACC].[Document]( [DocumentID] [int] IDENTITY(1,1) NOT NULL, [Date]
Given the following table structure: CREATE TABLE IF NOT EXISTS `roles` ( `id` int(11)
I have the following structure: CREATE TABLE IF NOT EXISTS `myTable` ( `ID` int(11)
My table structure is: CREATE TABLE IF NOT EXISTS `users_settings_temp` ( `id` int(10) unsigned
I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);

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.