Re: Containable + HABTM + conditions PROBLEM [urgent]

2009-07-06 Thread Andreas D.

Thanks, but it doesn't work.
Gives me this query:
SELECT `Module`.`id`, `Module`.`position`, `Module`.`name`,
`Module`.`created`, `Module`.`modified` FROM `modules` AS `Module`
WHERE `Version`.`name` = 'covermount'

and this error:
1054: Unknown column 'Version.name' in 'where clause'

On 3 Jul., 20:14, brian bally.z...@gmail.com wrote:
 Something like this?

 $modules = $this-Product-Module-find(
         'all',
         array(
                 'conditions' = array(
                         'Version.name' = $version
                 ),
                 'contain' = array(
                         'Version' = array(
                                 'fields' = array('*')
                         )
                 )
         )
 );

 On Fri, Jul 3, 2009 at 6:00 AM, Andreas Derksenandreasderk...@arcor.de 
 wrote:
  Hi all,
  i got some problems with my habtm containable setup. This is it:

  Product HABTM Module
  Module HABTM Version

  in the Product controller i want to find all modules that belong to an
  certain version defined in the Version model.

  this was my approach:
  $this-Product-id = $id;
  $this-Product-find('first', array('contain' = array('Module' =
  array('conditions' = array('Version.name' = $version);

  but it says:

  Unknown column 'Version.name' in 'where clause'

  how do i query it with or without the Containable behavior?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Containable + HABTM + conditions PROBLEM [urgent]

2009-07-06 Thread Andreas D.

Well, I think the quick tip from nate about ad.hoc joins (
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find
) is exactly what I need.
I tried it like this:
$checklist = $this-Checklist-Product-Module-find('matches', 
array
(
'model' = 'Version',
'scope' = array('Version.name' = 'short')
));
this gives me:
SQL Error: 1054: Unknown column 'Module.Version' in 'field list' [CORE
\cake\libs\model\datasources\dbo_source.php, line 525]
with this sql:
Query: SELECT `Module`.`Version`, `Module`.`Array`, `Module`.`id` FROM
`modules` AS `Module`   WHERE matchesLIMIT 1

why he does an sql like this?!
i just copied the code from nates post to my appcontroller...

perhaps its easier in normal sql, but as im not an sql professional i
wanted to do it the cakeish way..

Thanks for any help...


On 6 Jul., 09:31, Andreas D. andreasderk...@arcor.de wrote:
 Thanks, but it doesn't work.
 Gives me this query:
 SELECT `Module`.`id`, `Module`.`position`, `Module`.`name`,
 `Module`.`created`, `Module`.`modified` FROM `modules` AS `Module`
 WHERE `Version`.`name` = 'covermount'

 and this error:
 1054: Unknown column 'Version.name' in 'where clause'

 On 3 Jul., 20:14, brian bally.z...@gmail.com wrote:

  Something like this?

  $modules = $this-Product-Module-find(
          'all',
          array(
                  'conditions' = array(
                          'Version.name' = $version
                  ),
                  'contain' = array(
                          'Version' = array(
                                  'fields' = array('*')
                          )
                  )
          )
  );

  On Fri, Jul 3, 2009 at 6:00 AM, Andreas Derksenandreasderk...@arcor.de 
  wrote:
   Hi all,
   i got some problems with my habtm containable setup. This is it:

   Product HABTM Module
   Module HABTM Version

   in the Product controller i want to find all modules that belong to an
   certain version defined in the Version model.

   this was my approach:
   $this-Product-id = $id;
   $this-Product-find('first', array('contain' = array('Module' =
   array('conditions' = array('Version.name' = $version);

   but it says:

   Unknown column 'Version.name' in 'where clause'

   how do i query it with or without the Containable behavior?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Containable + HABTM + conditions PROBLEM [urgent]

2009-07-03 Thread Andreas Derksen
Hi all,
i got some problems with my habtm containable setup. This is it:

Product HABTM Module
Module HABTM Version

in the Product controller i want to find all modules that belong to an 
certain version defined in the Version model.

this was my approach:
$this-Product-id = $id;
$this-Product-find('first', array('contain' = array('Module' = 
array('conditions' = array('Version.name' = $version);

but it says:

Unknown column 'Version.name' in 'where clause'


how do i query it with or without the Containable behavior?


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



Re: Containable + HABTM + conditions PROBLEM [urgent]

2009-07-03 Thread brian

Something like this?

$modules = $this-Product-Module-find(
'all',
array(
'conditions' = array(
'Version.name' = $version
),
'contain' = array(
'Version' = array(
'fields' = array('*')
)
)
)
);

On Fri, Jul 3, 2009 at 6:00 AM, Andreas Derksenandreasderk...@arcor.de wrote:
 Hi all,
 i got some problems with my habtm containable setup. This is it:

 Product HABTM Module
 Module HABTM Version

 in the Product controller i want to find all modules that belong to an
 certain version defined in the Version model.

 this was my approach:
 $this-Product-id = $id;
 $this-Product-find('first', array('contain' = array('Module' =
 array('conditions' = array('Version.name' = $version);

 but it says:

 Unknown column 'Version.name' in 'where clause'

 how do i query it with or without the Containable behavior?


 


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