Re: FindAll and Recursive

2008-01-08 Thread [EMAIL PROTECTED]

I show   my real application.

Model A:

Class Informazione .


var $belongsTo = array('InformazioneTipo' =
  );

 var $hasAndBelongsToMany = array('InformazioneCampo' =
 );

In model A I change the fields returned on  associated model.

Model B :

class InformazioneTipo .


var $hasMany = array('Informazione' =
);


 var $hasAndBelongsToMany = array('InformazioneCampo' =
  );




Model C:
class InformazioneCampo  ..


 var $hasAndBelongsToMany = array('InformazioneTipo' =
 );



  View for findAll without recursive:


Array
(
[0] = Array
(
[Informazione] = Array
(
[informazione_id] = .
)

[InformazioneTipo] = Array
(
[tipo_id] = 
)
 [InformazioneCampo] = Array
(
[0] = Array
(
[campo_id] = 
)
  )

And this is all ok



View for findAll with recursive=3:


Array
(
[0] = Array
(
[Informazione] = Array
(
[informazione_id] = 
)

[InformazioneTipo] = Array
(
[tipo_id] = 1...
[Informazione] = Array
(
[0] = Array
(
[informazione_id] = 
[InformazioneTipo] = Array
(
[tipo_id] = 
)

[InformazioneCampo] = Array
(
)  /*This is empty ERROR*/

)

)

[InformazioneCampo] = Array
(
[0] = Array
(
[campo_id] = 
)
)
   )

On 7 Gen, 20:13, AD7six [EMAIL PROTECTED] wrote:
 On Jan 7, 8:11 pm, AD7six [EMAIL PROTECTED] wrote:

  You overwrote the find method, just to change the fields returned on
  an associated model?

 Whoops I clicked send too soon.

 I find that a bit A given that B and and should be used to do C.

 Where:
 A = strange
 B = bindModel/your association definitions
 C = the same thing.

 hth,

 AD
 PS. Real names are easier to understand.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



FindAll and Recursive

2008-01-07 Thread [EMAIL PROTECTED]

Hi
I have this question.
I  have a model A where I change the methods findAll and find.
Now I have another model B that is in hasMany association with this
model.
Now if in the controller I make a find operation on model A I get the
right result.
If I  make a find operation on model B with recursive=2  I don't get
the right result for model A associated with model B.
How can I do to get the right result even if I use recursive?
Many Thanks
Marco
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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: FindAll and Recursive

2008-01-07 Thread [EMAIL PROTECTED]

Sorry I have mistaked.
A has belongsTo Association with B
A has hasAndBelongsToMany Association with C
B has hasMany Association with A

I change the methods findAll and find for A where  I change the field
of the model C that I get normally with findAll and find.

I make a findAll operation on model A with recursive 3


I get this



A--|
B--|
A--|
C


The field of C is empty.



Instead if I make a findAll operation on model A with recursive 0
iget



A--|
B
 |
C

With C that is not empty



On 7 Gen, 19:24, francky06l [EMAIL PROTECTED] wrote:
 Sorry, a bit unclear to me :

 A hasMany B ?
 B has got which relation with A ?

 On Jan 7, 7:18 pm, [EMAIL PROTECTED]

 [EMAIL PROTECTED] wrote:
  Hi
  I have this question.
  I  have a model A where I change the methods findAll and find.
  Now I have another model B that is in hasMany association with this
  model.
  Now if in the controller I make a find operation on model A I get the
  right result.
  If I  make a find operation on model B with recursive=2  I don't get
  the right result for model A associated with model B.
  How can I do to get the right result even if I use recursive?
  Many Thanks
  IInstead nstead Marco
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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: FindAll and Recursive

2008-01-07 Thread AD7six



On Jan 7, 7:48 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Sorry I have mistaked.
 A has belongsTo Association with B
 A has hasAndBelongsToMany Association with C
 B has hasMany Association with A

 I change the methods findAll and find for A where  I change the field
 of the model C that I get normally with findAll and find.

You overwrote the find method, just to change the fields returned on
an associated model?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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: FindAll and Recursive

2008-01-07 Thread AD7six



On Jan 7, 8:11 pm, AD7six [EMAIL PROTECTED] wrote:
 You overwrote the find method, just to change the fields returned on
 an associated model?

Whoops I clicked send too soon.

I find that a bit A given that B and and should be used to do C.

Where:
A = strange
B = bindModel/your association definitions
C = the same thing.

hth,

AD
PS. Real names are easier to understand.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



findAll and $recursive option

2007-08-27 Thread bunyan

Hello!

I have three models - City, State and Vacancy.

City belongs to state and vacancy belongs to city.
Setting $this-Vacancy-recursive = 2 and then calling $this-Vacancy-
findAll() with no parameters returns the Vacancy, City and State
data. But if I call $this-Vacancy-findAll() with array of fields as
a second parameter, $this-Vacancy-recursive is ignored, and I get
only Vacancy and City data.

How can I both use the fields array and recursive option?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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: findAll and $recursive option

2007-08-27 Thread Freight

Have looked at this? Perhaps sixth parameter!

http://api.cakephp.org/class_model.html#63ade7d3c6d03c83ab53a224e23ad9dd


Model::findAll  (   $conditions = null,
$   fields = null,
$   order = null,
$   limit = null,
$   page = 1,
$   recursive = null
)

Returns a resultset array with specified fields from database matching
given conditions. By using the $recursive parameter, the call can
access further levels of association than the ones this model is
directly associated to.

Parameters:
mixed   $conditions SQL conditions as a string or as an
array('field' ='value',...)
mixed   $fields Either a single string of a field name, or an
array of field names
string  $order SQL ORDER BY conditions (e.g. price DESC or
name ASC)
int $limit SQL LIMIT clause, for calculating items per page.
int $page Page number, for accessing paged data
int $recursive The number of levels deep to fetch associated
records

Returns:
array Array of records public

Definition at line 1123 of file model_php5.php.

References $recursive, __resetAssociations(), afterFind(),
beforeFind(), ConnectionManager::getDataSource(), getID(), and
read().


On 27 Aug., 09:12, bunyan [EMAIL PROTECTED] wrote:
 Hello!

 I have three models - City, State and Vacancy.

 City belongs to state and vacancy belongs to city.
 Setting $this-Vacancy-recursive = 2 and then calling 
 $this-Vacancy-findAll() with no parameters returns the Vacancy, City and 
 State

 data. But if I call $this-Vacancy-findAll() with array of fields as
 a second parameter, $this-Vacancy-recursive is ignored, and I get
 only Vacancy and City data.

 How can I both use the fields array and recursive option?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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: findAll and $recursive option

2007-08-27 Thread bunyan

Thanks, but it's the same as $this-Vacancy-recursive.

Manual:

$recursive

This sets the number of levels you wish Cake to fetch associated model
data in find() and findAll() operations.


On 27 авг, 23:33, Freight [EMAIL PROTECTED] wrote:
 Have looked at this? Perhaps sixth parameter!

 http://api.cakephp.org/class_model.html#63ade7d3c6d03c83ab53a224e23ad9dd

 Model::findAll  (   $conditions = null,
 $   fields = null,
 $   order = null,
 $   limit = null,
 $   page = 1,
 $   recursive = null
 )

 Returns a resultset array with specified fields from database matching
 given conditions. By using the $recursive parameter, the call can
 access further levels of association than the ones this model is
 directly associated to.

 Parameters:
 mixed   $conditions SQL conditions as a string or as an
 array('field' ='value',...)
 mixed   $fields Either a single string of a field name, or an
 array of field names
 string  $order SQL ORDER BY conditions (e.g. price DESC or
 name ASC)
 int $limit SQL LIMIT clause, for calculating items per page.
 int $page Page number, for accessing paged data
 int $recursive The number of levels deep to fetch associated
 records

 Returns:
 array Array of records public

 Definition at line 1123 of file model_php5.php.

 References $recursive, __resetAssociations(), afterFind(),
 beforeFind(), ConnectionManager::getDataSource(), getID(), and
 read().

 On 27 Aug., 09:12, bunyan [EMAIL PROTECTED] wrote:

  Hello!

  I have three models - City, State and Vacancy.

  City belongs to state and vacancy belongs to city.
  Setting $this-Vacancy-recursive = 2 and then calling 
  $this-Vacancy-findAll() with no parameters returns the Vacancy, City and 
  State

  data. But if I call $this-Vacancy-findAll() with array of fields as
  a second parameter, $this-Vacancy-recursive is ignored, and I get
  only Vacancy and City data.

  How can I both use the fields array and recursive option?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---