Re: how to add a relationship whit other key different to the PK

2010-05-12 Thread Martin Westin
Sorry for not noticing your reply until now.

In that case you might get away with simply telling the relationship
that the foreign key is software_id.




On Apr 28, 4:02 pm, Manolet Gmail  wrote:
> the problem is that i need to user the value of software_id for the query.
>
> for example, the HasMany query should be:
>
> SELECT `Mirror`.`id`,   FROM `mirrors` AS `Mirror` WHERE
> `Mirror`.`software_id` = (6)
>
> But how i can put in the query, or in the conditions value add the id of
> software_id??
>
> Thanks in advance
>
> On Wed, Apr 28, 2010 at 4:35 AM, Martin Westin
> wrote:
>
>
>
>
>
> > You can set foreign_key to false and instead use the condition of the
> > relationship. This is usually used for things like User.active => true
> > and simple things like that but I think it can be used for your
> > purpose.
>
> > COme to think of it, I may be wrong. I vaguely recall an RC for
> > Cake1.2 causing problems when the condition is not an array... and I
> > think you might need a string contition.
>
> > On Apr 28, 12:54 am, Manolet Gmail  wrote:
> > > Hi, i have this tables:
>
> > > Software
> > > Reviews
> > > Mirror
> > > Requirements
> > > Published
>
> > > Now, this is the relations:
>
> > > Software Has Many Reviews
> > > Software Has Many Mirrors
> > > Software HABTM Requirements
>
> > > Works fine.
>
> > > The problem is that i need to resume the tables to get a better response
> > > from mysql, the reviews tables have text fields and are classified by
> > > language, so, for the public site i do a Published table for each
> > language,
> > > i mean: language_en language_es language_fr and load the data
> > automatically
> > > into that tables...
>
> > > The Published table is a merge of the Software and Review Table. The PK
> > of
> > > Published table is 'id', and is the same number of the reviews table.
>
> > > I want to establish this relationship: Published.software_id (not the PK)
> > > Has Many Mirrors.software_id
>
> > > The key has a Unique index, the problem is that aparently i can use the
> > > foreign_key attribute when declaring the relationship to set the Mirror
> > > model field, but i cant set the field that i want to use on the Published
> > > model, it uses the PK by default.
>
> > > Is there a way to force it to use other key different to the PK for the
> > > queries?
>
> > > Currently im using afterFind function and works okey, but dont allows me
> > to
> > > use "contain" or "fields".
>
> > > Hope you can understand me and help me
>
> > > thanks for you time,
>
> > > Manolo
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
> > with their CakePHP related questions.
>
> > > 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
> > > cake-php+unsubscr...@googlegroups.com > >  om>For more options, visit this group athttp://
> > groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > 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
> > cake-php+unsubscr...@googlegroups.com > om>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: how to add a relationship whit other key different to the PK

2010-04-28 Thread Manolet Gmail
the problem is that i need to user the value of software_id for the query.

for example, the HasMany query should be:

SELECT `Mirror`.`id`,   FROM `mirrors` AS `Mirror` WHERE
`Mirror`.`software_id` = (6)

But how i can put in the query, or in the conditions value add the id of
software_id??

Thanks in advance

On Wed, Apr 28, 2010 at 4:35 AM, Martin Westin
wrote:

> You can set foreign_key to false and instead use the condition of the
> relationship. This is usually used for things like User.active => true
> and simple things like that but I think it can be used for your
> purpose.
>
> COme to think of it, I may be wrong. I vaguely recall an RC for
> Cake1.2 causing problems when the condition is not an array... and I
> think you might need a string contition.
>
>
> On Apr 28, 12:54 am, Manolet Gmail  wrote:
> > Hi, i have this tables:
> >
> > Software
> > Reviews
> > Mirror
> > Requirements
> > Published
> >
> > Now, this is the relations:
> >
> > Software Has Many Reviews
> > Software Has Many Mirrors
> > Software HABTM Requirements
> >
> > Works fine.
> >
> > The problem is that i need to resume the tables to get a better response
> > from mysql, the reviews tables have text fields and are classified by
> > language, so, for the public site i do a Published table for each
> language,
> > i mean: language_en language_es language_fr and load the data
> automatically
> > into that tables...
> >
> > The Published table is a merge of the Software and Review Table. The PK
> of
> > Published table is 'id', and is the same number of the reviews table.
> >
> > I want to establish this relationship: Published.software_id (not the PK)
> > Has Many Mirrors.software_id
> >
> > The key has a Unique index, the problem is that aparently i can use the
> > foreign_key attribute when declaring the relationship to set the Mirror
> > model field, but i cant set the field that i want to use on the Published
> > model, it uses the PK by default.
> >
> > Is there a way to force it to use other key different to the PK for the
> > queries?
> >
> > Currently im using afterFind function and works okey, but dont allows me
> to
> > use "contain" or "fields".
> >
> > Hope you can understand me and help me
> >
> > thanks for you time,
> >
> > Manolo
> >
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
> >
> > 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
> > cake-php+unsubscr...@googlegroups.comFor
> >  more options, visit this group athttp://
> groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: how to add a relationship whit other key different to the PK

2010-04-28 Thread Martin Westin
You can set foreign_key to false and instead use the condition of the
relationship. This is usually used for things like User.active => true
and simple things like that but I think it can be used for your
purpose.

COme to think of it, I may be wrong. I vaguely recall an RC for
Cake1.2 causing problems when the condition is not an array... and I
think you might need a string contition.


On Apr 28, 12:54 am, Manolet Gmail  wrote:
> Hi, i have this tables:
>
> Software
> Reviews
> Mirror
> Requirements
> Published
>
> Now, this is the relations:
>
> Software Has Many Reviews
> Software Has Many Mirrors
> Software HABTM Requirements
>
> Works fine.
>
> The problem is that i need to resume the tables to get a better response
> from mysql, the reviews tables have text fields and are classified by
> language, so, for the public site i do a Published table for each language,
> i mean: language_en language_es language_fr and load the data automatically
> into that tables...
>
> The Published table is a merge of the Software and Review Table. The PK of
> Published table is 'id', and is the same number of the reviews table.
>
> I want to establish this relationship: Published.software_id (not the PK)
> Has Many Mirrors.software_id
>
> The key has a Unique index, the problem is that aparently i can use the
> foreign_key attribute when declaring the relationship to set the Mirror
> model field, but i cant set the field that i want to use on the Published
> model, it uses the PK by default.
>
> Is there a way to force it to use other key different to the PK for the
> queries?
>
> Currently im using afterFind function and works okey, but dont allows me to
> use "contain" or "fields".
>
> Hope you can understand me and help me
>
> thanks for you time,
>
> Manolo
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


how to add a relationship whit other key different to the PK

2010-04-27 Thread Manolet Gmail
Hi, i have this tables:

Software
Reviews
Mirror
Requirements
Published

Now, this is the relations:

Software Has Many Reviews
Software Has Many Mirrors
Software HABTM Requirements

Works fine.

The problem is that i need to resume the tables to get a better response
from mysql, the reviews tables have text fields and are classified by
language, so, for the public site i do a Published table for each language,
i mean: language_en language_es language_fr and load the data automatically
into that tables...

The Published table is a merge of the Software and Review Table. The PK of
Published table is 'id', and is the same number of the reviews table.

I want to establish this relationship: Published.software_id (not the PK)
Has Many Mirrors.software_id

The key has a Unique index, the problem is that aparently i can use the
foreign_key attribute when declaring the relationship to set the Mirror
model field, but i cant set the field that i want to use on the Published
model, it uses the PK by default.

Is there a way to force it to use other key different to the PK for the
queries?

Currently im using afterFind function and works okey, but dont allows me to
use "contain" or "fields".

Hope you can understand me and help me

thanks for you time,

Manolo

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en