Quantcast

Using find(list) to return results from multiple tables

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Using find(list) to return results from multiple tables

Siraris
Hi all

I'm totally stumped here.  I'm trying to create a data structure that I can feed into the Form Select helper to create an list with optgroups.  According to http://book.cakephp.org/1.3/view/1022/find-list I can do this, and yet my results are never returned the way I want them (they are reflected in the link above in the usernameGroups example at the bottom).

I thought that perhaps it wasn't working because I was pulling from another table than the one that was bound to my model, but when I tried pulling 3 fields from the same table, it still returned nothing like what I wanted (just using some ID's as the key, but all the values being blank, and nothing being nested).  

Can anyone help me out here?  This is the way my find call looks:  $result = $this->Project->find('list', array('conditions'=>array('Project.name != '=>'"Time Off"', 'Project.is_active'=>1), 'order'=>'Client.name', 'fields'=>array('Project.id, Project.name, Client.name'), 'contain'=>Array('Client'), 'recursive'=>1));

I want the client to be the parent node, and the project name and id to be the child nodes, with the ID being the key to the project name.  At this point, I could probably just do two separate finds and iterate over them to merge them together, but I'm feeling stubborn and want this to work.

Any help would be appreciated.

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Using find(list) to return results from multiple tables

Jeremy Burns | Class Outfit
What do the results currently look like?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 6 Sep 2012, at 20:27:57, Siraris <[hidden email]> wrote:

Hi all

I'm totally stumped here.  I'm trying to create a data structure that I can feed into the Form Select helper to create an list with optgroups.  According to http://book.cakephp.org/1.3/view/1022/find-list I can do this, and yet my results are never returned the way I want them (they are reflected in the link above in the usernameGroups example at the bottom).

I thought that perhaps it wasn't working because I was pulling from another table than the one that was bound to my model, but when I tried pulling 3 fields from the same table, it still returned nothing like what I wanted (just using some ID's as the key, but all the values being blank, and nothing being nested).  

Can anyone help me out here?  This is the way my find call looks:  $result = $this->Project->find('list', array('conditions'=>array('Project.name != '=>'"Time Off"', 'Project.is_active'=>1), 'order'=>'Client.name', 'fields'=>array('Project.id, Project.name, Client.name'), 'contain'=>Array('Client'), 'recursive'=>1));

I want the client to be the parent node, and the project name and id to be the child nodes, with the ID being the key to the project name.  At this point, I could probably just do two separate finds and iterate over them to merge them together, but I'm feeling stubborn and want this to work.

Any help would be appreciated.

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 
Loading...