Re: releted select

2009-12-02 Thread j0n4s.h4rtm...@googlemail.com
With Model->recursive you can just use associations and fetch data.
See http://book.cakephp.org/view/82/hasMany
in your ClientsController just do $this->set('clients', $this->Client-
>find('first', array('conditions' => array('Client.id' => $id;
In your clients/view.ctp debug($clients);

On Dec 1, 12:53 pm, Tom  wrote:
> Hi, I need help.
> How to view and select only projects for selected client?
>
> CREATE TABLE IF NOT EXISTS `projects` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `name` varchar(200) NOT NULL,
>   `client_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
>
> CREATE TABLE IF NOT EXISTS `clients` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `name` varchar(100) NOT NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
>
> CREATE TABLE IF NOT EXISTS `activities` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `client_id` int(11) NOT NULL,
>   `project_id` int(11) DEFAULT NULL,
>   PRIMARY KEY (`id`),
> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

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


releted select

2009-12-01 Thread Tom
Hi, I need help.
How to view and select only projects for selected client?

CREATE TABLE IF NOT EXISTS `projects` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `client_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `clients` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

CREATE TABLE IF NOT EXISTS `activities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL,
  `project_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

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