Re: CakePHP 2.0 Model relation alias, am I getting it wrong?

2011-10-31 Thread Jeremy Burns | Class Outfit
Maybe it was caching?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 31 Oct 2011, at 21:48, John wrote:

> Made a new database with just two tables to clean test this scenario
> and worked as documented. Then went back to the real (more complex)
> database where it doesn't and I still couldn't find anything wrong.
> 
> So I created a new working folder redoing the models with bake from
> the start and there it works. Now the strange part, there doesn't seem
> to be any difference in code (the $hasMany property in question or in
> general) between the working and non working model class file. I've
> diffed it just to prove to myself I'm not crazy!
> 
> So thanks for your time to reply, I appreciate it. I guess I shouldn't
> have jumped on the subject without clean testing it first and although
> I don't know what was wrong, it's solved so I'll move on...
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: CakePHP 2.0 Model relation alias, am I getting it wrong?

2011-10-31 Thread John
Made a new database with just two tables to clean test this scenario
and worked as documented. Then went back to the real (more complex)
database where it doesn't and I still couldn't find anything wrong.

So I created a new working folder redoing the models with bake from
the start and there it works. Now the strange part, there doesn't seem
to be any difference in code (the $hasMany property in question or in
general) between the working and non working model class file. I've
diffed it just to prove to myself I'm not crazy!

So thanks for your time to reply, I appreciate it. I guess I shouldn't
have jumped on the subject without clean testing it first and although
I don't know what was wrong, it's solved so I'll move on...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: CakePHP 2.0 Model relation alias, am I getting it wrong?

2011-10-31 Thread Jeremy Burns | Class Outfit
Are you getting an empty array key or no array key? What does your find query 
look like? Are you using the Containable behaviour? What is recursive set to?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 31 Oct 2011, at 12:52, John wrote:

> Hey guys, I'm rather new in CakePHP although I've developed a couple
> small projects back in the 1.1 era.
> 
> I've been puzzled with the model relation alias behavior in 2.0
> (behavior here used as literal english word not as the cakePHP
> entity).
> 
> According to the docs one can name different model relation aliases
> for the same model class, i.e.
> 
> class testExample extends AppModel {
>  public $hasMany = array(
>   'testRelation1' => array( //that's the alias
>   'className' => 'testRelation', //an existing model here
>   'foreignKey' => 'test_relation1_id' //existing key in 
> database
>   ),
>   'testRelation2' => array(
>   'className' => 'testRelation',
>   'foreignKey' => 'test_relation2_id' //another existing 
> key in the
> database
>   ),
> }
> 
> When the queries run, they return the expected results but those
> results are not shown on page data, probably suppressed at some point.
> The "Related Test Relation1" and "Related Test Relation2" come empty.
> 
> They only reason to get the data is to have the alias exactly as the
> model class name:
>  public $hasMany = array(
>   'testRelation' => array( //same as model class name
>   'className' => 'testRelation',
>   'foreignKey' => 'test_relation1_id',
>   )
> 
> Even if you have just one relation like the last example and the alias
> is not exactly the model name it doesn't work again.
> 
> Is this expected behavior?
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: CakePHP 2.0 Model relation alias, am I getting it wrong?

2011-10-31 Thread euromark
what happens if you use the official convention? CamelCase (not
camelBack)
'className' => 'TestRelation' etc


On 31 Okt., 13:52, John  wrote:
> Hey guys, I'm rather new in CakePHP although I've developed a couple
> small projects back in the 1.1 era.
>
> I've been puzzled with the model relation alias behavior in 2.0
> (behavior here used as literal english word not as the cakePHP
> entity).
>
> According to the docs one can name different model relation aliases
> for the same model class, i.e.
>
> class testExample extends AppModel {
>   public $hasMany = array(
>                 'testRelation1' => array( //that's the alias
>                         'className' => 'testRelation', //an existing model 
> here
>                         'foreignKey' => 'test_relation1_id' //existing key in 
> database
>                 ),
>                 'testRelation2' => array(
>                         'className' => 'testRelation',
>                         'foreignKey' => 'test_relation2_id' //another 
> existing key in the
> database
>                 ),
>
> }
>
> When the queries run, they return the expected results but those
> results are not shown on page data, probably suppressed at some point.
> The "Related Test Relation1" and "Related Test Relation2" come empty.
>
> They only reason to get the data is to have the alias exactly as the
> model class name:
>   public $hasMany = array(
>                 'testRelation' => array( //same as model class name
>                         'className' => 'testRelation',
>                         'foreignKey' => 'test_relation1_id',
>                 )
>
> Even if you have just one relation like the last example and the alias
> is not exactly the model name it doesn't work again.
>
> Is this expected behavior?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


CakePHP 2.0 Model relation alias, am I getting it wrong?

2011-10-31 Thread John
Hey guys, I'm rather new in CakePHP although I've developed a couple
small projects back in the 1.1 era.

I've been puzzled with the model relation alias behavior in 2.0
(behavior here used as literal english word not as the cakePHP
entity).

According to the docs one can name different model relation aliases
for the same model class, i.e.

class testExample extends AppModel {
  public $hasMany = array(
'testRelation1' => array( //that's the alias
'className' => 'testRelation', //an existing model here
'foreignKey' => 'test_relation1_id' //existing key in 
database
),
'testRelation2' => array(
'className' => 'testRelation',
'foreignKey' => 'test_relation2_id' //another existing 
key in the
database
),
}

When the queries run, they return the expected results but those
results are not shown on page data, probably suppressed at some point.
The "Related Test Relation1" and "Related Test Relation2" come empty.

They only reason to get the data is to have the alias exactly as the
model class name:
  public $hasMany = array(
'testRelation' => array( //same as model class name
'className' => 'testRelation',
'foreignKey' => 'test_relation1_id',
)

Even if you have just one relation like the last example and the alias
is not exactly the model name it doesn't work again.

Is this expected behavior?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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