Re: Newbie questions about model relations

2008-10-19 Thread Marritza


Meanwhile, I have thoroughly re-read the manual on the associations, spent
some time recreating db structure, rewritten the associations and now it
works.

Not to mention some small typos in the params (all that camel-case and
stuff)

Thanks anyway!
(case closed)


teknoid-3 wrote:
> 
> 
> Where is the model association between Design and Status and vice
> versa?
> Your models need to know how they relate to each other.
> Please review the manual as it quite clearly describes all of the
> that.
> 
> 
> 
> On Oct 18, 12:06 pm, Marritza <[EMAIL PROTECTED]> wrote:
>> Ok, let me clarify finally. (Never used newsgroups before so pardon lack
>> of
>> complete information :P )
>>
>> class Design extends AppModel {
>>
>>         var $primaryKey = 'designs_id';
>>         var $useTable = 'design';
>>
>> }
>>
>> class Status extends AppModel {
>>
>>         var $primaryKey = 'status_id';
>>         var $useTable = 'status';
>>
>> }
>>
>> I'm not using foreign keys. The db schema has been posted in the first
>> message.
>>
>>
>>
>> teknoid-3 wrote:
>>
>> > If you cannot alter db structure, that's fine. Cake works perfectly
>> > well with legacy DB's, but you have to ensure that you specify any
>> > settings that do not follow conventions. That includes table names,
>> > primary keys as well as foreign keys.
>>
>> > You didn't provide your model definitions, so it's hard to guess as to
>> > what could be culprit.
>>
>> > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
>> >> Forgot to mention - I am using $prmaryKey syntax in each model,
>> because I
>> >> have limited possibilities to alter the db structure. Tho, it is
>> possible
>> >> for me to create a sample table using cake conventions, I'll try again
>> >> then.
>>
>> >> teknoid-3 wrote:
>>
>> >> > You shouldn't break conventions when naming your primary keys.
>> >> > Cake will expect your primary key to be named 'id'... So Design.id
>> and
>> >> > Status.id.
>>
>> >> > Of course you can override those by setting a $prmaryKey =
>> 'myOwnKey';
>> >> > in the model, but why make your life more difficult?
>>
>> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
>> >> >> Hello!
>>
>> >> >> I'm using Cake for several days now, I'm still under big impression
>> of
>> >> >> its
>> >> >> capabilities.
>>
>> >> >> Nevertheless, I have faced a problem, to which solution, which I
>> have
>> >> >> found,
>> >> >> feels not logical in the Cake ways of doing things. First, let me
>> show
>> >> >> you
>> >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>>
>> >> >> table DESIGNS
>> >> >> designs_id serial <- primary key
>> >> >> job_name
>> >> >> status_id
>> >> >> ...etc
>>
>> >> >> table STATUS
>> >> >> status_id serial <- primary key
>> >> >> name
>>
>> >> >> The expected outcome is simple - I'm querying the Design model to
>> >> >> retrieve
>> >> >> data about a job, and I expect to see the status name which is
>> related
>> >> >> thru
>> >> >> Design.status_id => Status.status_id.
>>
>> >> >> Now, when I tried to accomplish it with $hasOne in the Design model
>> >> the
>> >> >> result is that Status is joined not on the forementioned basis, but
>> on
>> >> >> Design.design_id -> Status.status_id.
>>
>> >> >> to my surprise, it works using $belongsTo relation.
>>
>> >> >> Perhaps there is something wrong with my understanding of the Cake
>> >> >> relation
>> >> >> ways, perhaps I'm simply overlooking some basic stuff.
>>
>> >> >> Anyhow, any help greatly appreciated.
>>
>> >> >> --
>> >> >> View this message in
>>
>> >>
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> >> >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> >> --
>> >> View this message in
>> >>
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20059649.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-19 Thread teknoid

Where is the model association between Design and Status and vice
versa?
Your models need to know how they relate to each other.
Please review the manual as it quite clearly describes all of the
that.



On Oct 18, 12:06 pm, Marritza <[EMAIL PROTECTED]> wrote:
> Ok, let me clarify finally. (Never used newsgroups before so pardon lack of
> complete information :P )
>
> class Design extends AppModel {
>
>         var $primaryKey = 'designs_id';
>         var $useTable = 'design';
>
> }
>
> class Status extends AppModel {
>
>         var $primaryKey = 'status_id';
>         var $useTable = 'status';
>
> }
>
> I'm not using foreign keys. The db schema has been posted in the first
> message.
>
>
>
> teknoid-3 wrote:
>
> > If you cannot alter db structure, that's fine. Cake works perfectly
> > well with legacy DB's, but you have to ensure that you specify any
> > settings that do not follow conventions. That includes table names,
> > primary keys as well as foreign keys.
>
> > You didn't provide your model definitions, so it's hard to guess as to
> > what could be culprit.
>
> > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
> >> Forgot to mention - I am using $prmaryKey syntax in each model, because I
> >> have limited possibilities to alter the db structure. Tho, it is possible
> >> for me to create a sample table using cake conventions, I'll try again
> >> then.
>
> >> teknoid-3 wrote:
>
> >> > You shouldn't break conventions when naming your primary keys.
> >> > Cake will expect your primary key to be named 'id'... So Design.id and
> >> > Status.id.
>
> >> > Of course you can override those by setting a $prmaryKey = 'myOwnKey';
> >> > in the model, but why make your life more difficult?
>
> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
> >> >> Hello!
>
> >> >> I'm using Cake for several days now, I'm still under big impression of
> >> >> its
> >> >> capabilities.
>
> >> >> Nevertheless, I have faced a problem, to which solution, which I have
> >> >> found,
> >> >> feels not logical in the Cake ways of doing things. First, let me show
> >> >> you
> >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>
> >> >> table DESIGNS
> >> >> designs_id serial <- primary key
> >> >> job_name
> >> >> status_id
> >> >> ...etc
>
> >> >> table STATUS
> >> >> status_id serial <- primary key
> >> >> name
>
> >> >> The expected outcome is simple - I'm querying the Design model to
> >> >> retrieve
> >> >> data about a job, and I expect to see the status name which is related
> >> >> thru
> >> >> Design.status_id => Status.status_id.
>
> >> >> Now, when I tried to accomplish it with $hasOne in the Design model
> >> the
> >> >> result is that Status is joined not on the forementioned basis, but on
> >> >> Design.design_id -> Status.status_id.
>
> >> >> to my surprise, it works using $belongsTo relation.
>
> >> >> Perhaps there is something wrong with my understanding of the Cake
> >> >> relation
> >> >> ways, perhaps I'm simply overlooking some basic stuff.
>
> >> >> Anyhow, any help greatly appreciated.
>
> >> >> --
> >> >> View this message in
>
> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> >> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> >> --
> >> View this message in
> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> View this message in 
> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread Pablo Viojo
You are wrong, you can name your id whatever you want as long as you  
define it using $primaryKey

Sent from my iPhone

On 18-10-2008, at 16:43, "Lamonte(Scheols/Demonic)"  
<[EMAIL PROTECTED]> wrote:

> Yeah cake its strict on everything  so you can't name your id  
> "design_id" stupid? Yes I know.
>
> On Sat, Oct 18, 2008 at 11:06 AM, Marritza <[EMAIL PROTECTED]> wrote:
>
>
> Ok, let me clarify finally. (Never used newsgroups before so pardon  
> lack of
> complete information :P )
>
> class Design extends AppModel {
>
>var $primaryKey = 'designs_id';
>var $useTable = 'design';
> }
>
> class Status extends AppModel {
>
>var $primaryKey = 'status_id';
>var $useTable = 'status';
> }
>
> I'm not using foreign keys. The db schema has been posted in the first
> message.
>
>
> teknoid-3 wrote:
> >
> >
> > If you cannot alter db structure, that's fine. Cake works perfectly
> > well with legacy DB's, but you have to ensure that you specify any
> > settings that do not follow conventions. That includes table names,
> > primary keys as well as foreign keys.
> >
> > You didn't provide your model definitions, so it's hard to guess  
> as to
> > what could be culprit.
> >
> > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
> >> Forgot to mention - I am using $prmaryKey syntax in each model,  
> because I
> >> have limited possibilities to alter the db structure. Tho, it is  
> possible
> >> for me to create a sample table using cake conventions, I'll try  
> again
> >> then.
> >>
> >>
> >>
> >> teknoid-3 wrote:
> >>
> >> > You shouldn't break conventions when naming your primary keys.
> >> > Cake will expect your primary key to be named 'id'... So  
> Design.id and
> >> > Status.id.
> >>
> >> > Of course you can override those by setting a $prmaryKey =  
> 'myOwnKey';
> >> > in the model, but why make your life more difficult?
> >>
> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
> >> >> Hello!
> >>
> >> >> I'm using Cake for several days now, I'm still under big  
> impression of
> >> >> its
> >> >> capabilities.
> >>
> >> >> Nevertheless, I have faced a problem, to which solution, which  
> I have
> >> >> found,
> >> >> feels not logical in the Cake ways of doing things. First, let  
> me show
> >> >> you
> >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian  
> Etch).
> >>
> >> >> table DESIGNS
> >> >> designs_id serial <- primary key
> >> >> job_name
> >> >> status_id
> >> >> ...etc
> >>
> >> >> table STATUS
> >> >> status_id serial <- primary key
> >> >> name
> >>
> >> >> The expected outcome is simple - I'm querying the Design model  
> to
> >> >> retrieve
> >> >> data about a job, and I expect to see the status name which is  
> related
> >> >> thru
> >> >> Design.status_id => Status.status_id.
> >>
> >> >> Now, when I tried to accomplish it with $hasOne in the Design  
> model
> >> the
> >> >> result is that Status is joined not on the forementioned  
> basis, but on
> >> >> Design.design_id -> Status.status_id.
> >>
> >> >> to my surprise, it works using $belongsTo relation.
> >>
> >> >> Perhaps there is something wrong with my understanding of the  
> Cake
> >> >> relation
> >> >> ways, perhaps I'm simply overlooking some basic stuff.
> >>
> >> >> Anyhow, any help greatly appreciated.
> >>
> >> >> --
> >> >> View this message in
> >> >>
> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418
> >>  
> ...
> >> >> Sent from the CakePHP mailing list archive at Nabble.com.
> >>
> >> --
> >> View this message in
> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418
> >>  
> ...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
> > >
> >
> >
>
> --
> View this message in context: 
> http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
>
>
>
>
> -- 
> Join cleanscript.com Come here for professional PHP coding.
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread Joel Perras

> Yeah cake its strict on everything  so you can't name your id "design_id"
> stupid? Yes I know.

Thank you for indicating that you have no idea what you're talking
about. Go back to selling $70 websites and leave the rest of the
internet in peace.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread Lamonte(Scheols/Demonic)
Yeah cake its strict on everything  so you can't name your id "design_id"
stupid? Yes I know.

On Sat, Oct 18, 2008 at 11:06 AM, Marritza <[EMAIL PROTECTED]> wrote:

>
>
> Ok, let me clarify finally. (Never used newsgroups before so pardon lack of
> complete information :P )
>
> class Design extends AppModel {
>
>var $primaryKey = 'designs_id';
>var $useTable = 'design';
> }
>
> class Status extends AppModel {
>
>var $primaryKey = 'status_id';
>var $useTable = 'status';
> }
>
> I'm not using foreign keys. The db schema has been posted in the first
> message.
>
>
> teknoid-3 wrote:
> >
> >
> > If you cannot alter db structure, that's fine. Cake works perfectly
> > well with legacy DB's, but you have to ensure that you specify any
> > settings that do not follow conventions. That includes table names,
> > primary keys as well as foreign keys.
> >
> > You didn't provide your model definitions, so it's hard to guess as to
> > what could be culprit.
> >
> > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
> >> Forgot to mention - I am using $prmaryKey syntax in each model, because
> I
> >> have limited possibilities to alter the db structure. Tho, it is
> possible
> >> for me to create a sample table using cake conventions, I'll try again
> >> then.
> >>
> >>
> >>
> >> teknoid-3 wrote:
> >>
> >> > You shouldn't break conventions when naming your primary keys.
> >> > Cake will expect your primary key to be named 'id'... So Design.id and
> >> > Status.id.
> >>
> >> > Of course you can override those by setting a $prmaryKey = 'myOwnKey';
> >> > in the model, but why make your life more difficult?
> >>
> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
> >> >> Hello!
> >>
> >> >> I'm using Cake for several days now, I'm still under big impression
> of
> >> >> its
> >> >> capabilities.
> >>
> >> >> Nevertheless, I have faced a problem, to which solution, which I have
> >> >> found,
> >> >> feels not logical in the Cake ways of doing things. First, let me
> show
> >> >> you
> >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
> >>
> >> >> table DESIGNS
> >> >> designs_id serial <- primary key
> >> >> job_name
> >> >> status_id
> >> >> ...etc
> >>
> >> >> table STATUS
> >> >> status_id serial <- primary key
> >> >> name
> >>
> >> >> The expected outcome is simple - I'm querying the Design model to
> >> >> retrieve
> >> >> data about a job, and I expect to see the status name which is
> related
> >> >> thru
> >> >> Design.status_id => Status.status_id.
> >>
> >> >> Now, when I tried to accomplish it with $hasOne in the Design model
> >> the
> >> >> result is that Status is joined not on the forementioned basis, but
> on
> >> >> Design.design_id -> Status.status_id.
> >>
> >> >> to my surprise, it works using $belongsTo relation.
> >>
> >> >> Perhaps there is something wrong with my understanding of the Cake
> >> >> relation
> >> >> ways, perhaps I'm simply overlooking some basic stuff.
> >>
> >> >> Anyhow, any help greatly appreciated.
> >>
> >> >> --
> >> >> View this message in
> >> >>
> >> context:
> http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> >> >> Sent from the CakePHP mailing list archive at Nabble.com.
> >>
> >> --
> >> View this message in
> >> context:
> http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
> > >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>


-- 
Join cleanscript.com Come here for professional PHP coding.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread Marritza


Ok, let me clarify finally. (Never used newsgroups before so pardon lack of
complete information :P )

class Design extends AppModel {

var $primaryKey = 'designs_id';
var $useTable = 'design';
}

class Status extends AppModel {

var $primaryKey = 'status_id';
var $useTable = 'status';
}

I'm not using foreign keys. The db schema has been posted in the first
message.


teknoid-3 wrote:
> 
> 
> If you cannot alter db structure, that's fine. Cake works perfectly
> well with legacy DB's, but you have to ensure that you specify any
> settings that do not follow conventions. That includes table names,
> primary keys as well as foreign keys.
> 
> You didn't provide your model definitions, so it's hard to guess as to
> what could be culprit.
> 
> On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
>> Forgot to mention - I am using $prmaryKey syntax in each model, because I
>> have limited possibilities to alter the db structure. Tho, it is possible
>> for me to create a sample table using cake conventions, I'll try again
>> then.
>>
>>
>>
>> teknoid-3 wrote:
>>
>> > You shouldn't break conventions when naming your primary keys.
>> > Cake will expect your primary key to be named 'id'... So Design.id and
>> > Status.id.
>>
>> > Of course you can override those by setting a $prmaryKey = 'myOwnKey';
>> > in the model, but why make your life more difficult?
>>
>> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
>> >> Hello!
>>
>> >> I'm using Cake for several days now, I'm still under big impression of
>> >> its
>> >> capabilities.
>>
>> >> Nevertheless, I have faced a problem, to which solution, which I have
>> >> found,
>> >> feels not logical in the Cake ways of doing things. First, let me show
>> >> you
>> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>>
>> >> table DESIGNS
>> >> designs_id serial <- primary key
>> >> job_name
>> >> status_id
>> >> ...etc
>>
>> >> table STATUS
>> >> status_id serial <- primary key
>> >> name
>>
>> >> The expected outcome is simple - I'm querying the Design model to
>> >> retrieve
>> >> data about a job, and I expect to see the status name which is related
>> >> thru
>> >> Design.status_id => Status.status_id.
>>
>> >> Now, when I tried to accomplish it with $hasOne in the Design model
>> the
>> >> result is that Status is joined not on the forementioned basis, but on
>> >> Design.design_id -> Status.status_id.
>>
>> >> to my surprise, it works using $belongsTo relation.
>>
>> >> Perhaps there is something wrong with my understanding of the Cake
>> >> relation
>> >> ways, perhaps I'm simply overlooking some basic stuff.
>>
>> >> Anyhow, any help greatly appreciated.
>>
>> >> --
>> >> View this message in
>> >>
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread teknoid

If you cannot alter db structure, that's fine. Cake works perfectly
well with legacy DB's, but you have to ensure that you specify any
settings that do not follow conventions. That includes table names,
primary keys as well as foreign keys.

You didn't provide your model definitions, so it's hard to guess as to
what could be culprit.

On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote:
> Forgot to mention - I am using $prmaryKey syntax in each model, because I
> have limited possibilities to alter the db structure. Tho, it is possible
> for me to create a sample table using cake conventions, I'll try again then.
>
>
>
> teknoid-3 wrote:
>
> > You shouldn't break conventions when naming your primary keys.
> > Cake will expect your primary key to be named 'id'... So Design.id and
> > Status.id.
>
> > Of course you can override those by setting a $prmaryKey = 'myOwnKey';
> > in the model, but why make your life more difficult?
>
> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
> >> Hello!
>
> >> I'm using Cake for several days now, I'm still under big impression of
> >> its
> >> capabilities.
>
> >> Nevertheless, I have faced a problem, to which solution, which I have
> >> found,
> >> feels not logical in the Cake ways of doing things. First, let me show
> >> you
> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>
> >> table DESIGNS
> >> designs_id serial <- primary key
> >> job_name
> >> status_id
> >> ...etc
>
> >> table STATUS
> >> status_id serial <- primary key
> >> name
>
> >> The expected outcome is simple - I'm querying the Design model to
> >> retrieve
> >> data about a job, and I expect to see the status name which is related
> >> thru
> >> Design.status_id => Status.status_id.
>
> >> Now, when I tried to accomplish it with $hasOne in the Design model the
> >> result is that Status is joined not on the forementioned basis, but on
> >> Design.design_id -> Status.status_id.
>
> >> to my surprise, it works using $belongsTo relation.
>
> >> Perhaps there is something wrong with my understanding of the Cake
> >> relation
> >> ways, perhaps I'm simply overlooking some basic stuff.
>
> >> Anyhow, any help greatly appreciated.
>
> >> --
> >> View this message in
> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> View this message in 
> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-18 Thread Marritza


Forgot to mention - I am using $prmaryKey syntax in each model, because I
have limited possibilities to alter the db structure. Tho, it is possible
for me to create a sample table using cake conventions, I'll try again then.


teknoid-3 wrote:
> 
> 
> You shouldn't break conventions when naming your primary keys.
> Cake will expect your primary key to be named 'id'... So Design.id and
> Status.id.
> 
> Of course you can override those by setting a $prmaryKey = 'myOwnKey';
> in the model, but why make your life more difficult?
> 
> On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
>> Hello!
>>
>> I'm using Cake for several days now, I'm still under big impression of
>> its
>> capabilities.
>>
>> Nevertheless, I have faced a problem, to which solution, which I have
>> found,
>> feels not logical in the Cake ways of doing things. First, let me show
>> you
>> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>>
>> table DESIGNS
>> designs_id serial <- primary key
>> job_name
>> status_id
>> ...etc
>>
>> table STATUS
>> status_id serial <- primary key
>> name
>>
>> The expected outcome is simple - I'm querying the Design model to
>> retrieve
>> data about a job, and I expect to see the status name which is related
>> thru
>> Design.status_id => Status.status_id.
>>
>> Now, when I tried to accomplish it with $hasOne in the Design model the
>> result is that Status is joined not on the forementioned basis, but on
>> Design.design_id -> Status.status_id.
>>
>> to my surprise, it works using $belongsTo relation.
>>
>> Perhaps there is something wrong with my understanding of the Cake
>> relation
>> ways, perhaps I'm simply overlooking some basic stuff.
>>
>> Anyhow, any help greatly appreciated.
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20046244.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie questions about model relations

2008-10-17 Thread teknoid

You shouldn't break conventions when naming your primary keys.
Cake will expect your primary key to be named 'id'... So Design.id and
Status.id.

Of course you can override those by setting a $prmaryKey = 'myOwnKey';
in the model, but why make your life more difficult?

On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm using Cake for several days now, I'm still under big impression of its
> capabilities.
>
> Nevertheless, I have faced a problem, to which solution, which I have found,
> feels not logical in the Cake ways of doing things. First, let me show you
> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch).
>
> table DESIGNS
> designs_id serial <- primary key
> job_name
> status_id
> ...etc
>
> table STATUS
> status_id serial <- primary key
> name
>
> The expected outcome is simple - I'm querying the Design model to retrieve
> data about a job, and I expect to see the status name which is related thru
> Design.status_id => Status.status_id.
>
> Now, when I tried to accomplish it with $hasOne in the Design model the
> result is that Status is joined not on the forementioned basis, but on
> Design.design_id -> Status.status_id.
>
> to my surprise, it works using $belongsTo relation.
>
> Perhaps there is something wrong with my understanding of the Cake relation
> ways, perhaps I'm simply overlooking some basic stuff.
>
> Anyhow, any help greatly appreciated.
>
> --
> View this message in 
> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---