I think your problem is that you're asking cake to just bring you the id's:

array('fields' =>array('Manager.id <http://manager.id/>', 'Manager.user_id')

should be:

array('fields' =>array('Manager.id <http://manager.id/>', 'Manager.user_id',
'User.realname')

On Jan 31, 2008 8:09 PM, judouk <[EMAIL PROTECTED]> wrote:

>
> Hi list
>
> Once again, I find myself stuck.
>
> I have three tables - users - managers - projects.
> The users table has fields defined for users real name (user.realname)
> and an id (user.id),
> the managers table has fields defined for the user id
> (manager.user_id) and
> a projects table which has fields defined for project id (project.id)
> and managers id (project.manager_id).
>
> These arent the only fields but it makes it a little easier.
>
> I've defined my models to associate the three tables
>
> // models/manager.php
> <?php
> class Manager extends AppModel
> {
>  var $name = 'Manager';
>  var $hasone = array('User' =>
>    array(
>      'className' => 'User',
>      'conditions' => '',
>      'order' => '',
>      'dependent' => true,
>      'foreignKey' => 'user_id'
>    )
>  );
> }
> ?>
>
> and
>
> // models/project.php
> <?php
> class Project extends AppModel
> {
>  var $name = 'Project';
>  var $useTable = 'projects';
>
>  var $belongsTo = array(
>    'Manager' => array('className' => 'Manager',
>      'foreignKey' => 'manager_id',
>      'conditions' => '',
>      'fields' => '',
>      'order' => ''
>    );
> }
> ?>
>
>
> What I want to be able to do is in my projects view is to see the
> fullname of the manager.
> I can get the managers user ID by adding the following within my
> projects controller...
>
>      $l = $this->Job->Manager->find('all', array('fields' =>
> array('Manager.id', 'Manager.user_id')));
>      $result = Set::combine($l, "{n}.Manager.id",
> "{n}.Manager.user_id");
>      $this->set('managers', $result);
>
> and in my projects view, I can use $managers to create a select list.
>
> What I cant seem to work out is how to see the managers fullname
> instead of his/her userid.
> I believe this is because its not inside my projects model but I'm
> really not sure.
>
>
> I hope that is enough information.
> Any help would be gratefully received.
> Thanks
> JudoUK
>
>
> >
>


-- 
Matias Lespiau
http://www.gignus.com/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to