Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Containable + HABTM + conditions PROBLEM [urgent]
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andreas Derksen  
View profile  
 More options Jul 3, 6:00 am
From: Andreas Derksen <andreasderk...@arcor.de>
Date: Fri, 03 Jul 2009 12:00:44 +0200
Local: Fri, Jul 3 2009 6:00 am
Subject: Containable + HABTM + conditions PROBLEM [urgent]

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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
brian  
View profile  
 More options Jul 3, 2:14 pm
From: brian <bally.z...@gmail.com>
Date: Fri, 3 Jul 2009 14:14:00 -0400
Subject: Re: Containable + HABTM + conditions PROBLEM [urgent]
Something like this?

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas D.  
View profile  
 More options Jul 6, 3:31 am
From: "Andreas D." <andreasderk...@arcor.de>
Date: Mon, 6 Jul 2009 00:31:02 -0700 (PDT)
Local: Mon, Jul 6 2009 3:31 am
Subject: Re: Containable + HABTM + conditions PROBLEM [urgent]
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas D.  
View profile  
 More options Jul 6, 4:33 am
From: "Andreas D." <andreasderk...@arcor.de>
Date: Mon, 6 Jul 2009 01:33:45 -0700 (PDT)
Local: Mon, Jul 6 2009 4:33 am
Subject: Re: Containable + HABTM + conditions PROBLEM [urgent]
Well, I think the quick tip from nate about ad.hoc joins (
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-...
) 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 matches    LIMIT 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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google