that is covered in book http://book.cakephp.org/

add in Task Model
var $belongsTo = array('User');

now $this->Task->find('all') will contain related user record.


On Dec 20, 6:33 pm, vikas <[email protected]> wrote:
> Hello friends..
>
> once again need help..
>
> I have a users table and projects table in my database.
>
> which has a field given below.
>
> Table: users
>
> `id` int(11) NOT NULL auto_increment,
>   `username` varchar(100) NOT NULL,
>   `password` varchar(100) NOT NULL,
>   `email` varchar(255) default NULL,
>   `user_role_id` int(11) NOT NULL,
>   `first_name` varchar(255) default NULL,
>   `last_name` varchar(255) default NULL,
>   `created` datetime NOT NULL,
>   `modified` datetime NOT NULL,
>   `status` tinyint(1) default NULL,
>   PRIMARY KEY  (`id`)
>
> Table: tasks
>
> `id` int(11) NOT NULL auto_increment,
>   `project_id` int(11) default NULL,
>   `task_type_id` int(11) default NULL,
>   `task_status_id` int(11) default NULL,
>   `user_id` int(11) default NULL,
>   `name` varchar(255) default NULL,
>   `details` text,
>   `status` tinyint(4) NOT NULL,
>   `created` datetime NOT NULL,
>   `modified` datetime NOT NULL,
>
> now in my view/index of tasks, instead of user_id I want to display
> username.
>
> How it is possible.?
>
> My index() coding for tasks_controller.php is:
>
> function index() {
>                 $this->set('tasks',$this->Task->find('all'));
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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