Re: HABTM Relationships Problem

2009-03-18 Thread nhathoang nhathoang
I hope you can post your database , I think you are not wrong in
configuring , but It difficult to answer you if you don't post database and
say more about your achivement

2009/3/19 Pete Bekisz 

> Hi all,
>
> I'm having some problems with saving HABTM relationships, and I was hoping
> you could help me.  The two models in question are Registrant and Product.
>
> In my Registrant model, I have a method that builds an array that looks
> like this:
>
> Array
> (
> [Registrant] => Array
> (
> [id] => 133
> )
>
> [Product] => Array
> (
> [0] => Array
> (
> [product_id] => 1
> [quantity] => 5
> [cost] => 25.00
> )
>
> [1] => Array
> (
> [product_id] => 2
> [quantity] => 1
> [cost] => 8.50
> [option_id] => 13
> )
>
> [2] => Array
> (
> [product_id] => 2
> [quantity] => 9
> [cost] => 76.50
> [option_id] => 14
> )
>
> [3] => Array
> (
> [product_id] => 2
> [quantity] => 3
> [cost] => 25.50
> [option_id] => 15
> )
>
> )
>
> )
>
> When I try using $this->saveAll($array) it does nothing, and when I try using 
> $this->Product->saveAll($array), this is the SQL it runs:
>
> 44START TRANSACTION0045SELECT `ProductsRegistrant`.`registrant_id` FROM 
> `products_registrants` AS `ProductsRegistrant` WHERE 
> `ProductsRegistrant`.`product_id` = ''11046DELETE `ProductsRegistrant` FROM 
> `products_registrants` AS `ProductsRegistrant` WHERE 
> `ProductsRegistrant`.`product_id` = '' AND 
> `ProductsRegistrant`.`registrant_id` = (130)1047INSERT INTO 
> `products_registrants` (`product_id`,`registrant_id`) VALUES 
> ('','133')1048COMMIT
>
> I've been playing with this for quite a while and I can't figure out what's 
> wrong. Could someone offer some guidance, please?
>
>
> >
>

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



HABTM Relationships Problem

2009-03-18 Thread Pete Bekisz
Hi all,

I'm having some problems with saving HABTM relationships, and I was hoping
you could help me.  The two models in question are Registrant and Product.

In my Registrant model, I have a method that builds an array that looks like
this:

Array
(
[Registrant] => Array
(
[id] => 133
)

[Product] => Array
(
[0] => Array
(
[product_id] => 1
[quantity] => 5
[cost] => 25.00
)

[1] => Array
(
[product_id] => 2
[quantity] => 1
[cost] => 8.50
[option_id] => 13
)

[2] => Array
(
[product_id] => 2
[quantity] => 9
[cost] => 76.50
[option_id] => 14
)

[3] => Array
(
[product_id] => 2
[quantity] => 3
[cost] => 25.50
[option_id] => 15
)

)

)

When I try using $this->saveAll($array) it does nothing, and when I
try using $this->Product->saveAll($array), this is the SQL it runs:

44START TRANSACTION0045SELECT `ProductsRegistrant`.`registrant_id`
FROM `products_registrants` AS `ProductsRegistrant` WHERE
`ProductsRegistrant`.`product_id` = ''11046DELETE `ProductsRegistrant`
FROM `products_registrants` AS `ProductsRegistrant` WHERE
`ProductsRegistrant`.`product_id` = '' AND
`ProductsRegistrant`.`registrant_id` = (130)1047INSERT INTO
`products_registrants` (`product_id`,`registrant_id`) VALUES
('','133')1048COMMIT

I've been playing with this for quite a while and I can't figure out
what's wrong. Could someone offer some guidance, please?

--~--~-~--~~~---~--~~
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: relationships problem

2008-02-21 Thread alkemann

Category hasMany Post  , Post belongsTo Category , Post belongsTo
Locality

posts table must have these two fields:

category_id
locality_id

On Feb 17, 7:04 pm, andrewharlan <[EMAIL PROTECTED]> wrote:
> hello,
> i understand Post hasone category and hasone locality. but can i set
> category to $belongsto Post and locality as $belongsto Post ??
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



relationships problem

2008-02-18 Thread andrewharlan

hello,
i understand Post hasone category and hasone locality. but can i set
category to $belongsto Post and locality as $belongsto Post ??

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



relationships problem

2008-02-18 Thread andrewharlan

Can any1 help me with this? i understand Post $hasone category and
$hasone locality. but can i set category to $belongsto Post and
locality as $belongsto Post ??

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---