Re: How to search - A very strange find

2010-03-27 Thread WebbedIT
If you want to specify model 2 fields in your fin's field or
conditions arrays you need to force a join by changing the association
from hasMany to hasOne using un/bindmodel otherwise find will run two
queries fetching model1 first then running a separate query for model2
and combining the returned datasets.

However if you only want to limit what fields find returs for the
hasMany relationship you can do this with containable by specifying a
fields array for each model you include in your contains array.

HTH

Paul

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
Hello,

thanks for that idea ands that way, but after i try it, it will be
shown the hole array of Model2.
Where are my fault?

Marcus

On 27 Mrz., 06:11, Martin Radosta martinrado...@gmail.com wrote:
 |Your question is not clear, I guess you need this:

 $this-Model1-Behaviors-attach('Containable');
 |

 $this-Model1-find('first',
         array(
                 'conditions' =  array('Model1.id' =  $id),
                 'contain' =  array('Model2' =  array('fields' =  
 array('Model2.title', 'Model2.description', 'Model2.reservation_status'))),
                 'fields' =  
 array('Model1.id','Model1.title','Model1.description')
          )
 );

 On 03/26/2010 09:10 PM, amarradi wrote:

  I have to go to bed good night

  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

  To unsubscribe from this group, send email to 
  cake-php+unsubscribegooglegroups.com or reply to this email with the words 
  REMOVE ME as the subject.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
Now it runs Thanks a lot in that model.

In the other way the Model contained Model1 is empty but why?

Here is the code of my model1

 $this-Model2-Behaviors-attach('Containable');
$this-set('var1', $this-Model2-find('first',
array(
'conditions' = array('Model2.id' = $id),
'contain' = array('Model1' = array('fields'=
array('Model1.register_password'))),
'fields' = array(
'Model2.id',
'Model1.id',
'Model1.register_password',
'Model2.id',
'Model2.description',
)
)
)
);

The debug output looks so

Array
(
[WishlistEntry] = Array
(
[wishlist_id] = 1
[id] = 2
[title] = Text
[description] = Text
[reservation_status] = FREE
)

[Wishlist] = Array
(
[register_password] =
[id] =
)

)

Whats wrong with it





On 27 Mrz., 12:38, amarradi radis...@googlemail.com wrote:
 Hello,

 thanks for that idea ands that way, but after i try it, it will be
 shown the hole array of Model2.
 Where are my fault?

 Marcus

 On 27 Mrz., 06:11, Martin Radosta martinrado...@gmail.com wrote:

  |Your question is not clear, I guess you need this:

  $this-Model1-Behaviors-attach('Containable');
  |

  $this-Model1-find('first',
          array(
                  'conditions' =  array('Model1.id' =  $id),
                  'contain' =  array('Model2' =  array('fields' =  
  array('Model2.title', 'Model2.description', 'Model2.reservation_status'))),
                  'fields' =  
  array('Model1.id','Model1.title','Model1.description')
           )
  );

  On 03/26/2010 09:10 PM, amarradi wrote:

   I have to go to bed good night

   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 For more options, visit this group 
   athttp://groups.google.com/group/cake-php?hl=en

   To unsubscribe from this group, send email to 
   cake-php+unsubscribegooglegroups.com or reply to this email with the 
   words REMOVE ME as the subject.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
Now it runs Thanks a lot in that model.

In the other way the Model contained Model1 is empty but why?

Here is the code of my model1

 $this-Model2-Behaviors-attach('Containable');
$this-set('var1', $this-Model2-find('first',
array(
'conditions' = array('Model2.id' = $id),
'contain' = array('Model1' = array('fields'=
array('Model1.register_password'))),
'fields' = array(
'Model2.id',
'Model1.id',
'Model1.register_password',
'Model2.id',
'Model2.description',
)
)
)
);

The debug output looks so

Array
(
[Model2] = Array
(
[model2_id] = 1
[id] = 2
[title] = Text
[description] = Text
[reservation_status] = FREE
)

[Model1] = Array
(
[register_password] =
[id] =
)

)

Whats wrong with it

On 27 Mrz., 12:38, amarradi radis...@googlemail.com wrote:
 Hello,

 thanks for that idea ands that way, but after i try it, it will be
 shown the hole array of Model2.
 Where are my fault?

 Marcus

 On 27 Mrz., 06:11, Martin Radosta martinrado...@gmail.com wrote:

  |Your question is not clear, I guess you need this:

  $this-Model1-Behaviors-attach('Containable');
  |

  $this-Model1-find('first',
          array(
                  'conditions' =  array('Model1.id' =  $id),
                  'contain' =  array('Model2' =  array('fields' =  
  array('Model2.title', 'Model2.description', 'Model2.reservation_status'))),
                  'fields' =  
  array('Model1.id','Model1.title','Model1.description')
           )
  );

  On 03/26/2010 09:10 PM, amarradi wrote:

   I have to go to bed good night

   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 For more options, visit this group 
   athttp://groups.google.com/group/cake-php?hl=en

   To unsubscribe from this group, send email to 
   cake-php+unsubscribegooglegroups.com or reply to this email with the 
   words REMOVE ME as the subject.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
I knwo the fault because under that id in Model2 is no entry in model1

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
In Table of Model2 is the Model1_id and this id is the same like the
id in model1

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
In Table of Model2 is the Model1_id and this id is the same like the
id in model1

How did i build the select

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-27 Thread amarradi
The Bug is found in the model i have set an forgeignKey on hasOne.

Thanks a lot for the help @everyone

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread amarradi
I have to correct it because in the that have to be an other value
  $this-set('variable', $this-Model1-find('first',array(
                 'conditions' = array('Model1.id' = $id),
                 'recursive' =  1,
                 'fields' =
 array('Model1.id','Model1.title','Model1.description')
             )
             )
             );

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread Martin Radosta

try
'recursive' = -1


On 03/26/2010 05:23 PM, amarradi wrote:

I have to correct it because in the that have to be an other value
   

  $this-set('variable', $this-Model1-find('first',array(
 'conditions' =  array('Model1.id' =  $id),
 'recursive' =1,
 'fields' =
array('Model1.id','Model1.title','Model1.description')
 )
 )
 );
 

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

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or 
reply to this email with the words REMOVE ME as the subject.
   


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

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or 
reply to this email with the words REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread amarradi
Thanks for the tip but i get this sql error
Unknown column Model2.id' in 'field list'

Because there is an array in Model2.

[0]

[1]

I dont know how do i get an coorect dataset


On 26 Mrz., 21:31, Martin Radosta martinrado...@gmail.com wrote:
 try
      'recursive' = -1

 On 03/26/2010 05:23 PM, amarradi wrote:

  I have to correct it because in the that have to be an other value

    $this-set('variable', $this-Model1-find('first',array(
                   'conditions' =  array('Model1.id' =  $id),
                   'recursive' =    1,
                   'fields' =
  array('Model1.id','Model1.title','Model1.description')
               )
               )
               );

  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

  To unsubscribe from this group, send email to 
  cake-php+unsubscribegooglegroups.com or reply to this email with the words 
  REMOVE ME as the subject.

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread amarradi
The Question is how do i get the information from an/the associated
model

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread cricket
Which fields from Model2 do you want? Do you want anything from
Model2?

On Mar 26, 4:57 pm, amarradi radis...@googlemail.com wrote:
 The Question is how do i get the information from an/the associated
 model

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread amarradi
I want the title description and in the first version
reservation_status
i try it over contains or recursive 2 But no change



On 27 Mrz., 00:39, cricket zijn.digi...@gmail.com wrote:
 Which fields from Model2 do you want? Do you want anything from
 Model2?

 On Mar 26, 4:57 pm, amarradi radis...@googlemail.com wrote:

  The Question is how do i get the information from an/the associated
  model

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread amarradi
I have to go to bed good night

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: How to search - A very strange find

2010-03-26 Thread Martin Radosta

|Your question is not clear, I guess you need this:

$this-Model1-Behaviors-attach('Containable');
|

$this-Model1-find('first',
array(
'conditions' =  array('Model1.id' =  $id),
'contain' =  array('Model2' =  array('fields' =  
array('Model2.title', 'Model2.description', 'Model2.reservation_status'))),
'fields' =  
array('Model1.id','Model1.title','Model1.description')
)
);


On 03/26/2010 09:10 PM, amarradi wrote:

I have to go to bed good night

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

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or 
reply to this email with the words REMOVE ME as the subject.
   


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

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or 
reply to this email with the words REMOVE ME as the subject.