Re: Using HABTM

2012-02-16 Thread Sean
I discovered the problem that gave me the error. Now what I'm working on selecting the images and getting them saved in the join table. I have been able to manually populate the fields in the join table and verify that the association works. But when I create the selection form, the form appears t

Re: Using HABTM

2012-02-16 Thread Florin Trifu
Ok. Now I think I understand what you're trying to obtain. Please tell me again your problem. Best regards! On Thu, Feb 16, 2012 at 4:10 AM, Sean wrote: > Thanks for the reply, Florin. > > Auction hasMany AuctionImages is the way that it is currently set. The > problem is that it currently "use

Re: Using HABTM

2012-02-15 Thread Sean
Thanks for the reply, Florin. Auction hasMany AuctionImages is the way that it is currently set. The problem is that it currently "uses up" any AuctionImage that is associated with the Auction. Each image is associated with a particular auction_id. What I'm looking for is a way to have a set of i

Re: Using HABTM

2012-02-15 Thread Florin Trifu
Hi I don't know if my understanding is correct, but Auction hasMany AuctionImages and not HABTM. You should try to change that hasAndBelongsTo from the Auction model, of which I've never heard by the way, into hasMany. As by the error following the pattern "model_name_X is not associated with mod

Using HABTM

2012-02-15 Thread Sean
Hi all, I am trying to do something that I think is pretty common. I am working on an auction site and if I had say a auctions table and a auction_images table. I want to be able to use multiple images with multiple auctions. In other words - auction1 be associated with auction_image 1, 2, 3 & a

Re: Is this possible w/ CakePHP? Using HABTM insert of multiple records/rows (with multiple select box)

2011-02-10 Thread ShadowCross
See my reply to your other post on this same issue ("HABTM w/ Multiple Select type Field and saveAll() on multiple records.") On Feb 9, 9:21 pm, OldWest wrote: > Does anyone know if this is possible within the CakePHP framework? > > http://stackoverflow.com/questions/4950487/cakephp-multiple-entr

Is this possible w/ CakePHP? Using HABTM insert of multiple records/rows (with multiple select box)

2011-02-09 Thread OldWest
Does anyone know if this is possible within the CakePHP framework? http://stackoverflow.com/questions/4950487/cakephp-multiple-entry-fields-w-saveall-habtm-multiple-records-insert-not-savi -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new Cak

Re: Sorting using HABTM Join Table's additional field

2010-05-16 Thread WebbedIT
The problem here is that you need to force a join so that the field you want to sort the results by is included in the main query. Containable alone will not help as it will not force a join for you. Take a look at find's JOIN options http://book.cakephp.org/view/872/Joining-tables it should get

Re: Sorting using HABTM Join Table's additional field

2010-05-15 Thread Bogdan Bursuc
Try using Containable, it may help you: http://book.cakephp.org/view/1323/Containable Try doing something like: $this->Category->find('all', array('contain' => array('Post' => array('order' => 'CategoriesPost.postorder'; On Sat, May 15, 2010 at 1:25 PM, ashok.b wrote: > If I add a order col

Re: Sorting using HABTM Join Table's additional field

2010-05-15 Thread ashok.b
If I add a order column in Posts, then I won't be able to order the posts per category... What ever order I set to a post will be applicable across all categories that post is linked to... I'm looking for per category ordering of posts. On May 15, 8:55 am, Bogdan Bursuc wrote: > Add in your Post

Re: Sorting using HABTM Join Table's additional field

2010-05-15 Thread ashok.b
Didn't work :( More over, $this->Post->find('all') starts throwing an SQL error 'CategoriesPost.postorder' not found... On May 15, 8:55 am, Bogdan Bursuc wrote: > Add in your Post Model > > class Post extends AppModel { >      var $order = 'CategoriesPost.postorder'; > > } > > Anyway I wouldn't

Re: Sorting using HABTM Join Table's additional field

2010-05-15 Thread Bogdan Bursuc
Add in your Post Model class Post extends AppModel { var $order = 'CategoriesPost.postorder'; } Anyway I wouldn't do it like so. I would just add an order field on the Post model. It's easier. On Sat, May 15, 2010 at 1:24 AM, ashok.b wrote: > > > Hello Cake Gurus, here's my problem: > > T

Sorting using HABTM Join Table's additional field

2010-05-14 Thread ashok.b
Hello Cake Gurus, here's my problem: Table1: Posts id - int title - varchar Table2: Categories id - int name - varchar HABTM JoinTable: categories_posts id - int post_id - int category_id - int postorder - int As you can see, the join table contains a field called 'postorder' - This is for

Re: HABTM confusion was: How to add item using HABTM relation

2008-12-04 Thread Rob
Because the HABTM relationship causes Cake to do its' magic, you have to build the structure with all of the associated data you want to save. That article is showing you a behavior that will help you do that more easily, by giving you methods to do so. If you set debug to 3, you'll see the SQL

HABTM confusion was: How to add item using HABTM relation

2008-12-04 Thread Zeugme
Hi Rob and thanks, I did already what you show but the issue was on client side, I found the solution : name the HTML element with data[Person][Person][0] on a contract creation form witch is really not intuitive ! Now back the controller I have to delete a contract. I read here http://baker

Re: How to add item using HABTM relation

2008-12-03 Thread Rob
You need to structure the data so that it has the right data and keys for each record that will be added. Your $this->data['Contract']['Person'] would be an array of the data required for the person. Since it appears you are doing this in your contracts controller, you would need to get the ID f

How to add item using HABTM relation

2008-12-03 Thread Zeugme
Hi, How to add an item to a HABTM relation ? I have a Person and I have to add a Contract to that person. Here are the data on a view : data[Contract][type] : 12 data[Contract][name] : contract-AAaa data[Contract][Person] : 26 // Should I put the person id here ?? or something else ?? In fac

Re: "find" using HABTM relationship

2008-11-25 Thread [EMAIL PROTECTED]
I think I can explain it a little. It did not work because Cake does not get habtm data all in a single query. The condition you set is used for the initial query (which does not reach the User model). Set debug to 2 and check the sql output. You should see two queries (I think) for any normal ha

Re: "find" using HABTM relationship

2008-11-25 Thread pkclarke
Thanks to those who tried to help. I was unable to use "find" to retrieve the data based on the HABTM relationship. I ended up doing manually: <-- //lookup User based on email $user = $this->User->find('first', array( 'conditions'=>array('email'

Re: "find" using HABTM relationship

2008-11-25 Thread AD7six
On Nov 25, 1:26 am, pkclarke <[EMAIL PROTECTED]> wrote: > I'm a noob to CakePHP and have an issue with "find" returning results > from tables with a HABTM relationship. > > I have 2 tables that have a HABTM relationship: > >  - Site.id >  - Site.title > >  - User.id >  - User.name > > The HABTM

Re: "find" using HABTM relationship

2008-11-24 Thread Kyo
This might be what you are looking for. The Containable behavior will do the job. $options = array( 'conditions' => array('User.id' => 7), 'contain' => array( 'Site' => array('fields' => array('id', 'title')) ) ); $results = $this->User->find('all', $option

Re: "find" using HABTM relationship

2008-11-24 Thread pkclarke
How do I achieve the same as the query below then? SELECT a.id, a.title FROM sites a, site_users b, users c WHERE a.id = b.site_id AND c.id = b.user_id AND c.id = 7 It seems odd that the HABTM relationship doesn't enable it. On Nov 25, 1:58 pm, Kyo <[EMAIL PROTECTED]> wrote: > You can't put Us

Re: "find" using HABTM relationship

2008-11-24 Thread Kyo
You can't put User conditions in the Site query. --~--~-~--~~~---~--~~ 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 ema

"find" using HABTM relationship

2008-11-24 Thread pkclarke
I'm a noob to CakePHP and have an issue with "find" returning results from tables with a HABTM relationship. I have 2 tables that have a HABTM relationship: - Site.id - Site.title - User.id - User.name The HABTM join table is: - SiteUser.id - SiteUser.site_id - SiteUser.user_id The Sit

Re: Facing problem on Joining table using HABTM

2007-11-30 Thread [EMAIL PROTECTED]
More details are as below: on the view Test size checkboxMultiple('Service.Size', $sizes_list) ?> Test types checkboxMultiple('Service.Group', $groups_list) ?> Test Payments checkboxMultiple('Service.Payment', $payments_list) ?> And the name of the table must be gr

Re: Facing problem on Joining table using HABTM

2007-11-30 Thread [EMAIL PROTECTED]
More details are as below: on the view DogSizes checkboxMultiple('Service.Size', $sizes_list) ?> DogGroup_Types checkboxMultiple('Service.Group', $groups_list) ?> Payments_Types checkboxMultiple('Service.Payment', $payments_list) ?> And the name of the table must be g

Re: Facing problem on Joining table using HABTM

2007-11-30 Thread [EMAIL PROTECTED]
Thank you for your fast response... Thats on the controller i just generate the list of values and save.Here is the controller code. set('sizes_list', $this->Service->Size->generateList()); $this->set('groups_list', $this->Service->Group->generateList()); $this->set('payments_list', $this->S

Re: Facing problem on Joining table using HABTM

2007-11-30 Thread AD7six
On Nov 30, 11:39 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hai friends, > > I am facing a specfic problem on habtm.Incase the version i am using > is 1.2 pre_beta.Everything are working fine except the joining table. > > I am using three set of multiple checkbox.For that i am using th

Facing problem on Joining table using HABTM

2007-11-30 Thread [EMAIL PROTECTED]
Hai friends, I am facing a specfic problem on habtm.Incase the version i am using is 1.2 pre_beta.Everything are working fine except the joining table. I am using three set of multiple checkbox.For that i am using three table.Right now whats happening is first two tables are working fine that th

Re: How to select using HABTM?

2007-11-10 Thread R. Rajesh Jeba Anbiah
On Nov 9, 8:07 pm, Corie <[EMAIL PROTECTED]> wrote: > I'm a bit confused about how to select records from a table in a HABTM > association. > > I have categories and I have images. I want to get all the images in a > specific category. I don't think it's HABTM. How to define model associat

How to select using HABTM?

2007-11-09 Thread Corie
I'm a bit confused about how to select records from a table in a HABTM association. I have categories and I have images. I want to get all the images in a specific category. Models: class Category extends AppModel { var $name = 'Category'; var $hasAndBelongsToMany = array('Image

Re: Conditions using habtm associations

2006-10-27 Thread John David Anderson (_psychic_)
On Oct 27, 2006, at 8:57 AM, Gonçalo Marrafa wrote: > I would like to know how(if) i can impose conditions to the tuples of > Foo based on tuples of Bar. For example, can i findAll() only the > tuples of > Foo that have an associated Bar tuple with id = 1 ? > > Can Cake do this for me or do i

Conditions using habtm associations

2006-10-27 Thread Gonçalo Marrafa
Hi, bakers. I have two models (Foo and Bar) associated with each other through a habtm association. When i findAll() on the Foo model i get something like: Array ( [0] => Array ( [Foo] => Array ( [id] => 1 [name] =>

Re: Pluralisation of Download[s] when using HABTM

2006-07-03 Thread Larry E. Masters aka PhpNut
There is a way to override what cake expects but you step outside of the conventions when doing so.HABTM association:var $hasAndBelongsToMany = array(...snip...   'joinTable' => 'some_table_not_using_conventions'); -- /*** @author Larry E. Masters* @var string $userName* @param string $realName* @r

Re: Pluralisation of Download[s] when using HABTM

2006-07-03 Thread bertz
Wah?!! I thought it would reflect the active record realtionships, ok well thanks very much for your help both of you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send em

Re: Pluralisation of Download[s] when using HABTM

2006-07-03 Thread John David Anderson (_psychic_)
On Jul 3, 2006, at 1:34 PM, bertz wrote: > Ok I didnt think so since I thought it was the other way round so i > just went in and chage it to downloads_sounds instead and hey > presto it > worked..but when I changed sounds_streams to streams_sounds no > good > submission wasnt working. Ch

Re: Pluralisation of Download[s] when using HABTM

2006-07-03 Thread bertz
Martin wrote: > Stupid question but: > Is 'sounds_downloads' a typo? > it should be 'downloads_sounds' to work properly. Ok I didnt think so since I thought it was the other way round so i just went in and chage it to downloads_sounds instead and hey presto it worked..but when I changed soun

Re: Pluralisation of Download[s] when using HABTM

2006-07-03 Thread Martin
Stupid question but: Is 'sounds_downloads' a typo? it should be 'downloads_sounds' to work properly. --~--~-~--~~~---~--~~ 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@go

Pluralisation of Download[s] when using HABTM

2006-07-03 Thread bertz
Dear All, This one is an odd one I know and I appreciate at first it may look that there must be a common user error here but as far as I can see there is none. I have a model called 'sounds' which HABTM 'downloads' and HABTM 'streams'. I have created the join table 'sounds_downloads' and 'soun