Questions tagged with relationship

1 answer

1 vote

Asked by sebb86, on 3/1/10 in

Create relationships in both directions?

Hello,

when i create a relationship between two models, must i create that relationship in both directions, respectively in both models (model A $hasMany model B ----AND---- model B $belongsTo model A)?

Thanks for help.

Greetings.

2 answers

0 votes

Asked by sebb86, on 5/1/10 in

How to create a relationship/association from one table/model to itself?

Hello,

how can i create a relationship from one model to itself?

In my case, i have a model "ports" with primary key "id" and foreign key "uplink_id".

Thanks if someone can help.

Greetings :)

3 answers

0 votes

Asked by seph429, on 31/1/10 in

Relationship Problem

I am trying to configure CakePHP to act as a REST API for an app i'm writing.

I have 3 tables:


dishes {
 id,
 name,
 description
}

users {
 id,
 name,
 email
}

dishes_users {
 id,
 user_id,
 dish_id
}

I would like it so that when someone visits...

2 answers

0 votes

Asked by tzsoft, on 21/4/10 in

HasMany/Belongs relationship not working

Hi,

I am using 1.2.6 and I have 2 models User and UserType: User belongsTo UserType and UserType hasMany User.

The baked code is:

class User extends AppModel

{

var $name = 'User';

var $belongsTo = array('UserType' = array('className' =...

2 answers

0 votes

Asked by GnarlyYoyo, on 25/4/10 in

Duplicating a record and the associated records

Hello,

I have a database with relationships between tables.

Let's say I have a table called Movies and each Movie has many Frame.

I want users to be able to edit their Movie without affecting the Movie other users can see, which stays on-line.

So...

1 answer

0 votes

Asked by GnarlyYoyo, on 2/5/10 in

Model that belongs to several models

Hello,

Suppose that I have a model Building, which has many Flat

Each flat has many Window, but there are also some Window that are associated directly to a Building and do not belong to any Flat

In summary:

Building has many Window

Flat has many...

0 answers

0 votes

Asked by asanoki, on 26/5/10 in

Problem with database cascade relationships.

I have three models (with controllers):

- Product: Id, Title, Type_id

- Type: Id, Description

- ProductItem: Id, Product_id, Size, Sold_time

Relationships:

- Product: belongsTo(Type), hasMany(ProductItem)

- Type: hasMany(Product)

- ProductItem:...

1 answer

0 votes

Asked by rodcord, on 1/6/10 in

3 relationships between 2 tables

What is the correct way to make a relationship at Cake when I have two tables with three relationships between them, for example:

Table: users

Table: Computers

For each computer that I subscribe, I must have 3 users.

So computers have on the table...

1 answer

0 votes

Asked by kendugu, on 25/6/10 in

Containable Behavior that Returns All Siblings

I'm using the Containable behavior. I have the following structure:

User hasAndBelongsToMany Teams

I'm looking for a containment that, given the current user, returns the team and then all other users in that team, like...

1 answer

0 votes

Asked by rjtman, 3 weeks, 2 days ago in

Creating HABTM relationships within a table

I'm currently making an app that stores genealogical information about people. As part of this, I need to be able to distinguish relationships between people, such as a parent-child, sibling, etc.

I have a table that contains people, but what is...

1 answer

0 votes

Asked by deathau, 2 weeks, 4 days ago in

Undefined property error, but relationships seem correct

I'm having a slight problem that I can't figure out, but should be really simple.

I have the following model structure:


ProspectiveQuote [hasMany] QuoteUnit [belongsTo] Unit

but in my ProspectiveQuotesController the...

1 answer

0 votes

Asked by gregwhitworth, 2 weeks, 2 days ago in

Has Many issue...

Ok. I have a table called People and a table called clumps. Basically they are clumps of people that are on mailing lists. So I have many people to any one mailing list, so I have this in the top of my Person.php model:


	var $name =...

1 answer

0 votes

Asked by pastryking, 1 week, 3 days ago in

Do I have to use the InnoDB database Engine to enjoy the relationship model in cake php?

I currently have a database running on the Myisam Engine. I am trying to link various tables and their foreign keys together so when i retrieve an object I have the associated information in the object too. I have executed this code wise (using...

<< previous next >>