How do I limit HABTM results with find function?

2006-07-12 Thread [EMAIL PROTECTED]

I have a HABTM relationship between Products and Logos. When I use
something like this:

$this-set('data', $this-Product-find(id = 2, null, null, 1));

The result is the following:

Array
(
[Product] = Array
(
[id] = 2
[name] = Chase and Ken T-Shirt
[description] = Blandit autet irillam integer ...
[price] = 7.95
[quantity] =
[active] = 1
[featured] = 0
[cart] = 1
[brand_id] = 0
[created] =
[modified] =
)

[Logo] = Array
(
[0] = Array
(
[id] = 3
[name] = Screenprinted Gentex Logo
[location] = Back
[price] = 0.75
[company_id] = 1
)

[1] = Array
(
[id] = 4
[name] = Screenprinted Serious Cams Logo
[location] = Breast
[price] = 0.50
[company_id] = 2
)
)
)

However, when we end up having a bunch of logos, this result will be
enormous. How do I have the same result but limit the logos to having a
company_id of 1. I tried the following:

$this-set('data', $this-Product-find(id = 2 AND company_id = 1,
null, null, 1));
$this-set('data', $this-Product-find(id = 2 AND logo.company_id =
1, null, null, 1));

But neither seemed to work; the error says field company_id not
found. What to do?

Thanks in advance!


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



Re: How do I limit HABTM results with find function?

2006-07-12 Thread Samuel DeVore
try array('Logo.company_id'=1,'Product.id'=2) On 7/12/06, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:I have a HABTM relationship between Products and Logos. When I use
something like this:$this-set('data', $this-Product-find(id = 2, null, null, 1));The result is the following:Array([Product] = Array([id] = 2
[name] = Chase and Ken T-Shirt[description] = Blandit autet irillam integer ...[price] = 7.95[quantity] =[active] = 1
[featured] = 0[cart] = 1[brand_id] = 0[created] =[modified] =)[Logo] = Array([0] = Array
([id] = 3[name] = Screenprinted Gentex Logo[location] = Back[price] = 0.75[company_id] = 1
)[1] = Array([id] = 4[name] = Screenprinted Serious Cams Logo[location] = Breast
[price] = 0.50[company_id] = 2)))However, when we end up having a bunch of logos, this result will beenormous. How do I have the same result but limit the logos to having a
company_id of 1. I tried the following:$this-set('data', $this-Product-find(id = 2 AND company_id = 1,null, null, 1));$this-set('data', $this-Product-find(id = 2 AND 
logo.company_id =1, null, null, 1));But neither seemed to work; the error says field company_id notfound. What to do?Thanks in advance!
--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---


Re: How do I limit HABTM results with find function?

2006-07-12 Thread [EMAIL PROTECTED]

Thanks much for the help, but what exactly do you mean (and what syntax
should I use)?
Samuel DeVore wrote:
 try array('Logo.company_id'=1,'Product.id'=2)

 On 7/12/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 
  I have a HABTM relationship between Products and Logos. When I use
  something like this:
 
  $this-set('data', $this-Product-find(id = 2, null, null, 1));
 
  The result is the following:
 
  Array
  (
  [Product] = Array
  (
  [id] = 2
  [name] = Chase and Ken T-Shirt
  [description] = Blandit autet irillam integer ...
  [price] = 7.95
  [quantity] =
  [active] = 1
  [featured] = 0
  [cart] = 1
  [brand_id] = 0
  [created] =
  [modified] =
  )
 
  [Logo] = Array
  (
  [0] = Array
  (
  [id] = 3
  [name] = Screenprinted Gentex Logo
  [location] = Back
  [price] = 0.75
  [company_id] = 1
  )
 
  [1] = Array
  (
  [id] = 4
  [name] = Screenprinted Serious Cams Logo
  [location] = Breast
  [price] = 0.50
  [company_id] = 2
  )
  )
  )
 
  However, when we end up having a bunch of logos, this result will be
  enormous. How do I have the same result but limit the logos to having a
  company_id of 1. I tried the following:
 
  $this-set('data', $this-Product-find(id = 2 AND company_id = 1,
  null, null, 1));
  $this-set('data', $this-Product-find(id = 2 AND logo.company_id =
  1, null, null, 1));
 
  But neither seemed to work; the error says field company_id not
  found. What to do?
 
  Thanks in advance!
 
 
  
 

 --=_Part_241_20267607.1152747189681
 Content-Type: text/html; charset=ISO-8859-1
 X-Google-AttachSize: 4704

 try array('Logo.company_id'=gt;1,'a 
 href=http://Product.id;Product.id/a'=gt;2)nbsp; brbrdivspan 
 class=gmail_quoteOn 7/12/06, b class=gmail_sendernamea 
 href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/a/b
  lt;a href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/agt; 
 wrote:/spanblockquote class=gmail_quote style=border-left: 1px solid 
 rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;brI have 
 a HABTM relationship between Products and Logos. When I use
 brsomething like this:brbr$this-gt;set('data', 
 $this-gt;Product-gt;find(quot;id = 2quot;, null, null, 1));brbrThe 
 result is the 
 following:brbrArraybr(brnbsp;nbsp;nbsp;nbsp;[Product] =gt; 
 Arraybrnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;(brnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[id]
  =gt; 2
 brnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[name]
  =gt; Chase and Ken 
 T-Shirtbrnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[description]
  =gt; Blandit autet irillam integer 
 ...brnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[price]
  =gt; 
 7.95brnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[quantity]
  
 =gt;brnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;[active]
  =gt; 1br
 nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nb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