Need a little help with HABTM joins

2011-11-07 Thread Ernesto
Hi all. i have 2 models, Articles and Pieces. They should've been linked by a HABTM but i need to save some additional fields in the join table so i made 2x hasMany. Here's my situation: Article hasMany ArticlePiece Piece hasMany ArticlePiece ArticlePiece belongsTo Article Ar

Re: CakePHP 2.0.2: HABTM relations: Edit form seems to add relations instead of replacing them

2011-11-06 Thread majna
I don't see Post or Tag model in this app. Check this line https://github.com/ilmattodel93/IMattiDel93-s-Site/blob/master/app/Model/EpisodeRelease.php#L39 or other habtm associations. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new Ca

Re: CakePHP 2.0.2: HABTM relations: Edit form seems to add relations instead of replacing them

2011-11-06 Thread majna
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm *"unique*: If true (default value) cake will first delete existing relationship records in the foreign keys table before inserting new ones, when updating a record. So existing associa

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-06 Thread Jon Bennett
> Ok, I've upgraded to 2.0.2, changed the code of > EpisodeReleaseController.php, and i have fixed the add problem. Now I > am building the edit function. I have used the console cake bake > controller to create it, but it seems that each time I press save it > adds a new association. > Example; >

CakePHP 2.0.2: HABTM relations: Edit form seems to add relations instead of replacing them

2011-11-06 Thread Mattia Manzati
Hi all, I am building a download manager for my site. Now I am building the edit function for the downloads. I have used the console cake bake controller to create it, but it seems that each time I press save it adds a new association. Example: "Post" as been added with "TagA" and "TagC". I edit

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-05 Thread Mattia Manzati
Ok, I've upgraded to 2.0.2, changed the code of EpisodeReleaseController.php, and i have fixed the add problem. Now I am building the edit function. I have used the console cake bake controller to create it, but it seems that each time I press save it adds a new association. Example; "Post" as been

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Mattia Manzati
Ok, putted code on github. This is the repo: https://github.com/ilmattodel93/IMattiDel93-s-Site Thanks again for your help! ^^ On 2 Nov, 18:47, Thiago Belem wrote: > Put your code on Github or Gists and send us the link. > > Thiago Belem, enviado do meu Android > Em 02/11/2011 15:28, "Mattia Man

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Thiago Belem
Put your code on Github or Gists and send us the link. Thiago Belem, enviado do meu Android Em 02/11/2011 15:28, "Mattia Manzati" escreveu: > I Have already checked, and all table are already well related. Same > column type INT(11) and InnoDB powered. But I still have the > problem... :S > What

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Mattia Manzati
I Have already checked, and all table are already well related. Same column type INT(11) and InnoDB powered. But I still have the problem... :S What to do now? The code I am using works if I use cakephp1.3 On 2 Nov, 17:51, Jeremy Burns wrote: > Use InnoDB. As John says, it won't let you creat

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Jeremy Burns
Use InnoDB. As John says, it won't let you create RI between fields with different types (and it's very precise) and you get transactions thrwn in for good measure. On 2 Nov 2011, at 16:14, Jon Bennett wrote: >> I've had some similar trouble with 2.0 >> turned out the fields in the DB were not

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Jon Bennett
> I've had some similar trouble with 2.0 > turned out the fields in the DB were not the same type. > id on one table was a bigint and the foreign key on the relationship table > was a regular integer. > atenciosamente, With MySQL you can catch these errors at db schema level if you use foreign ke

Re: CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Werner Petry Moraes
x27;]['user_id'] = >> $this->Auth->User('user_id'); >> $this->EpisodeRelease->set($this->request->data); >> if($this->EpisodeRelease->saveAll($this->request->data)){ >> $this->Session->setFlash('

CakePHP2.0.1 - Problem with saving HABTM

2011-11-02 Thread Mattia Manzati
Flash('Release aggiunta con > successo. Sarà visualizzabile non appena un amministratore lo avrà > approvato.'); > //$this->redirect(array('action'=>'index')); > pr($this->request->data); > }else{

Problems with HABTM Pagnitaion and i18n

2011-10-06 Thread Jörg
Hello all, i need help. I had a brand model with $hasAndBelongsToMany = array('Category'); Category is a model with the translation on the field 'name' Now depending on a category filter in a searchbox I want to identify which brands are in the search area and which other catgeories are assigned

Miles J - Uploader - HABTM

2011-10-03 Thread styks1987
https://github.com/milesj/cake-uploader/issues/24 I have opened an issue about this problem. Does anybody have an idea of why it may not work? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and

Re: Cascade delete and HABTM

2011-09-20 Thread xamako
Hi! I was wrong thinking on HABTM. Everything is working ok :-) Thanks! On 20 sep, 12:01, WebbedIT wrote: > You would not want to delete the associated Service as the nature of > HABTM means that Service could be associated with any number of other > ServiceCategory. > > HTH

Re: Cascade delete and HABTM

2011-09-20 Thread WebbedIT
You would not want to delete the associated Service as the nature of HABTM means that Service could be associated with any number of other ServiceCategory. HTH, Paul -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site

Re: Cascade delete and HABTM

2011-09-19 Thread xamako
'with' => 'ServiceCategorieService', ), ); } #ServiceCategorieService class ServiceCategorieService extends AppModel { var $name = 'ServiceCategorieService'; var $useTable = 'servicecategories_services'; } On 1

Re: Manual entry for habtm linking table.

2011-09-19 Thread Ritesh R Aryal
ersTclasses->create(); > >                         $this->Teacher->TeachersTclasses- > > > >save($db_data); > > > but actually this just worked.. > > > $this->Teacher->query("INSERT INTO teachers_tclasses > >                  

Re: Cascade delete and HABTM

2011-09-19 Thread xamako
The "dependent" key is not avaible en HABTM http://book.cakephp.org/es/view/1044/hasAndBelongsToMany-HABTM Thanks On 19 sep, 16:41, Thomas Ploch wrote: > Have you set the 'dependent' key in *both* relationship configurations? > > Kind regards > Thomas > &g

Re: Cascade delete and HABTM

2011-09-19 Thread Thomas Ploch
Have you set the 'dependent' key in *both* relationship configurations? Kind regards Thomas Am 19.09.2011 16:32, schrieb xamako: Hi! I have the following relationship between HABTM tables: - services - service_categories - Servicecategories_services (the latter is what links the

Cascade delete and HABTM

2011-09-19 Thread xamako
Hi! I have the following relationship between HABTM tables: - services - service_categories - Servicecategories_services (the latter is what links the two tables above) Well, what I get is that when you delete a table record service_categories, records are automatically deleted from the table

Re: Manual entry for habtm linking table.

2011-09-19 Thread WebbedIT
                      (tclass_id, teacher_id) VALUES >                             (".$tclass_id.", ".$teacher['Teacher'] > ['id'].");"); > > Cheers Chris > > On Sep 16, 8:37 am, WebbedIT wrote: > > > > > > > > > If using

Re: Manual entry for habtm linking table.

2011-09-18 Thread porangi.chris
ut actually this just worked.. $this->Teacher->query("INSERT INTO teachers_tclasses (tclass_id, teacher_id) VALUES (".$tclass_id.", ".$teacher['Teacher'] ['id'].");"); Cheers Chris On Sep 16, 8:37 am, WebbedIT wrot

Re: Manual entry for habtm linking table.

2011-09-16 Thread WebbedIT
If using Cakes HABTM automagic the table should be named classes_teachers and have the following fields id (primary_key, auto_inc) class_id teacher_id After that it's a case of INSERT INTO classes_teachers (class_id, teacher_id) SELECT class_id, teacher_id FROM import_table HTH, Paul @phpM

Manual entry for habtm linking table.

2011-09-15 Thread porangi.chris
hi, First time user of cake with CI background, I have two tables teachers and classes that share a many to many relationship e.g. Teacher-Classes. I'm having to import the data from CSV files that have been exported from another system that we have limited access to.I've got the classes wor

Re: Habtm fields input and view very important plz

2011-09-15 Thread driss
Okay I'll try that and see thanks On Sep 15, 2:11 am, Jeremy Burns | Class Outfit wrote: > Don't do it as HABTM. Create a model and controller for the joining table and > use $belongsTo and $hasMany. > > Jeremy Burns > Class Outfit > > http://www.classoutfit.c

Re: Habtm fields input and view very important plz

2011-09-14 Thread Jeremy Burns | Class Outfit
Don't do it as HABTM. Create a model and controller for the joining table and use $belongsTo and $hasMany. Jeremy Burns Class Outfit http://www.classoutfit.com On 14 Sep 2011, at 23:12, driss wrote: > I have this data structure : > Product(Id,name); > Market(Id,name); > Pro

Re: Habtm fields input and view very important plz

2011-09-14 Thread driss
is no one can help me ? any help is welcome On Sep 14, 10:12 pm, driss wrote: > I have this data structure : > Product(Id,name); > Market(Id,name); > Product HABTM Market ( I mean that i could have products available in > many Market or store but the price is not the same f

Habtm fields input and view very important plz

2011-09-14 Thread driss
I have this data structure : Product(Id,name); Market(Id,name); Product HABTM Market ( I mean that i could have products available in many Market or store but the price is not the same for example this product X is available in Market1 and in Market2 but in market1 it's expensive than in Ma

Re: Issue with habtm

2011-09-07 Thread WebbedIT
Show us your form view code and then echo your resulting data array please. HTH, Paul -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To

Issue with habtm

2011-09-06 Thread Ruslan Inozemtsev
Hello, i'm trying to start using HABTM in Cake 1.3, but can't understand how can i add an realtion. Im trynig to create new relation between User and Project records in DB, but no data apperas in users_projects after im saving data :( My code is: $data = array( 'User'

Re: Pretty HABTM List Entry

2011-08-30 Thread O.J. Tibi
Hi Mondo, Paul is right, you should model-ise your join table, effectively creating a "hasMany through" association, since you're adding additional fields that are not part of the table's foreign keys. You might want to read this: http://book.cakephp.org/view/1650/hasMany-through-The-Join-Model

Re: Pretty HABTM List Entry

2011-08-29 Thread WebbedIT
emRecipe > - Item hasMany ItemRecipe > - ItemRecipe belongsTo Recipe and Item > > This way you can easily work with the extra fields in your join table > and run finds/paginates on it too. > > On Aug 28, 7:51 pm, Mondo wrote: > > > > > > > >

Re: Pretty HABTM List Entry

2011-08-29 Thread WebbedIT
28, 7:51 pm, Mondo wrote: > I have a Recipe, Item, and Units table/model. I have a HABTM > relationship with Recipe and Item, and I get the default multiple- > select box when adding/editing Recipe. (am using Bake for everything > for the most part). The problem is I need to associat

Pretty HABTM List Entry

2011-08-28 Thread Mondo
I have a Recipe, Item, and Units table/model. I have a HABTM relationship with Recipe and Item, and I get the default multiple- select box when adding/editing Recipe. (am using Bake for everything for the most part). The problem is I need to associate quantities and units with each Item. Sample

Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Figured it out myself... maybe I should give myself a 24-hour rule from the time I write my post to the time I actually post it :) Anyway, to get model deleting to work I set the 'dependent' property to True in the User model's hasMany relationship for AuthSourcesUser, and my array to save it l

Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Ok, I'm getting a little closer. Some digging in more documentation brought me to this array to use instead: Array ( [User] => Array ( [email] => (my email here) [first_name] => Ben [last_name] => McClure ) [AuthSource] => Array

Re: CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
Well, I realized as soon as I posted that the reason the auth_sources_users records aren't getting deleted is that their user_id fields are blank... so I don't know if there's going to be a problem deleting the records or not... But what am I doing wrong when saving the data using the manually-c

CakePHP 2 - HABTM saving issue

2011-08-27 Thread Ben McClure
x27; => 'AuthSource', 'foreignKey' => 'auth_source_id', 'conditions' => '', 'fields' => '', 'order' => '' ), 'User' => array( 'className' => 'User', 'fore

Re: Cake 2.0 beta: FormHelper + HABTM fields

2011-08-13 Thread mark_story
The way Cake generates HABTM inputs was changed for 2.0. Its supposed to be less magic, but it doesn't seem like that is the case in this situation. Having some more information on the rest of the form might help. -Mark On Aug 12, 3:23 pm, handsofaten wrote: > Hi - I'm working

Cake 2.0 beta: FormHelper + HABTM fields

2011-08-12 Thread handsofaten
Hi - I'm working with CakePHP 2.0 beta, and having some trouble with the expected FormHelper functionality. I have in my view something like this: $i = 0; foreach($terms as $term){ echo $this->Form->input('Term.'.$i.'.id'); $i++ } >From which I expect something like this to be generated: .

Re: HABTM can't save manually

2011-08-09 Thread mr_robot
hi john thanks for all the help (and the kind encouragement). i kinda of worked out a solution, posting here for others: $tag_count = count($artist['Tag']); $artist = $this->Tags->checkforUpdates($artist); if (count($artist['Tag'])>$tag_count){ // first save all the tags foreach($artist['Tag']

Re: HABTM can't save manually

2011-08-09 Thread John Andersen
, which is mentioned at the bottom of the page about saving HABTM data in the CakePHP book at: http://book.cakephp.org/view/1034/Saving-Related-Model-Data-HABTM Keep up the good work, enjoy, John On Aug 9, 8:27 pm, mr_robot wrote: > hi john. yea it's 1. > > i have got it working an

Re: HABTM can't save manually

2011-08-09 Thread mr_robot
t; 3 ), 'Artist' => array ( 'Artist' => array ( 0 => 7 // this being the artist_id ) ) ), ); but now it's deleting the already saved associations. which leads me to this habtmAdd behavior. http:

Re: HABTM can't save manually

2011-08-09 Thread John Andersen
rtist, thus replacing all previous tags added to the artist (this is how HABTM normally works). 3) You want to do something different from 1 and 2 above. In 1) you probably have to consider using a HasMany relationship between Artist and ArtistTag instead of the HABTM between Artist and Tag. In 2

Re: HABTM can't save manually

2011-08-09 Thread mr_robot
so found a solution. sort of. after building some forms and looking at the output, i see the format as follows: [Tag] => Array ( [name] => final2 [rank] => ) [Artist] => Array ( [Artist] => Array (

Re: HABTM can't save manually

2011-08-08 Thread mr_robot
. no luck adding the whole $artist array. it starts to do weird stuff - adding values from the artist table into the artist_tags table. very confusing. will try build a form but this is all very strange - i assumed relations would be straightforward...? -- Our newest site for the communit

Re: HABTM can't save manually

2011-08-08 Thread John Andersen
Yes, I saw that, but the book says you have to do it differently in order to do it automatically. You have to refer to the Artist like this: [code] $artist['Artist']['id'] = 184287; [/code] Observe that you should not just call the save method with the $artist['Tag'] data only, but the full $arti

Re: HABTM can't save manually

2011-08-08 Thread mr_robot
hi john thanks for the answer. but i am doing this: $artist['Tag'][1]['artist_id'] = 184287; regards -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related

Re: HABTM can't save manually

2011-08-07 Thread John Andersen
You have to populate the related models Id in your array, as it is explained in the CakePHP book at: http://book.cakephp.org/view/1034/Saving-Related-Model-Data-HABTM So for each Tag record, add the related Artist record with just the primary key of the Artist record. Enjoy, John On Aug 5, 2

HABTM can't save manually

2011-08-05 Thread mr_robot
hi there been pulling my hair out on this one for 2 days. i have two simple models. artist and tags. and i have a artists_tags database table with artist_id and tag_id. artist model class Artist extends AppModel { var $name = 'Artist'; var $hasAndBelongsToMany = array(

Many HABTM relations in a single joinTable ?

2011-07-31 Thread Shturm681
Hi, I wonder if it's possible to get many HABTM relations working in a single table ? For example I want my Products, Pages and News to be paired as HABTM with my Images. So I have table named "images_items" with a model named ImageItem and the table looks like this: id - IN

Re: Checkbox múltiples + HABTM

2011-07-27 Thread eraonline
it's working the problem about save with HABTM!!! My problem was: $pharmacy = new Pharmacy(); $this->set('pharmacies', $pharmacy->find('all')); The value of the parameter 'all' wasn't working. The next works!!! $pharmacy = new Pharmacy(); $this-&

Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)

2011-07-27 Thread eraonline
Ben it's working the problem about save with HABTM!!! My problem was: $pharmacy = new Pharmacy(); $this->set('pharmacies', $pharmacy->find('all')); The value of the parameter 'all' wasn't working. The next works!!! $pharmacy = new Pharmacy();

Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)

2011-07-27 Thread eraonline
Thank you very much!!! It's working and it's magic like some things in Cake... I have problems with save with HABTM, I published other post about it called "Checkbox múltiples + HABTM". Can you help with it? Thanks! era -- Our newest site for the community: CakePHP V

Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)

2011-07-27 Thread BenJsno
oups, I forgive a "Categorie" replacement. You must read "PharmaciesTurn" instead of "CategoriesTurn" On 27 juil, 09:50, BenJsno wrote: > Hello, > > -- in your controller function (add or edit): > ... > $pharmacies = $this->Turn->Pharmacy->find('list'); > // FOR SELECTED CHECKBOX : (only in

Re: Multiples Checkbox and hasAndBelongsToMany (HABTM)

2011-07-27 Thread BenJsno
Hello, -- in your controller function (add or edit): ... $pharmacies = $this->Turn->Pharmacy->find('list'); // FOR SELECTED CHECKBOX : (only in edit) $options['joins'] = array( array('table' => 'pharmacies_turns', 'alias' => 'PharmaciesTurn', 'type' => '

Checkbox múltiples + HABTM

2011-07-26 Thread eraonline
Hello. I can't save multiple checkbox in HABTM. My code is: MODEL array( 'className' => 'Pharmacy' ) ); var $validate = array( 'name' => array( 'rule' => 'notEmpty' ), ); } ?> array( 'className&

Multiples Checkbox and hasAndBelongsToMany (HABTM)

2011-07-26 Thread eraonline
Hello! I want to show in the view a list of checkbox of Pharmacies to assign to a Turn. Example: Turn: INPUT TEXT Pharmacies: CHKBOX1 CHKBOX2 CHKBOX3 Can help me with this? Thanks! eraonline -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the

Re: HABTM again!

2011-07-21 Thread gremlin
emove completely the model for your join table - the UsersLink model. 3) define a normal habtm relationship between the User model and the Link model. 4) read the manual before you start another project - all of this is clearly explained in many translations. On Jul 21, 10:45 am, Jeremy Burns | Class O

Re: HABTM again!

2011-07-21 Thread Jeremy Burns | Class Outfit
'className' => 'User', > 'foreignKey' => 'user_id', > 'conditions' => '', > 'fields' => '', > 'order' =&g

Re: HABTM again!

2011-07-21 Thread localhost
('table' => 'links', 'alias' => 'Link', 'type' => 'inner', 'conditions' => array( 'UsersLink.link_id = Link.id' )

Re: HABTM again!

2011-07-21 Thread localhost
=> array( 'className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', &#

Re: HABTM again!

2011-07-21 Thread Jeremy Burns | Class Outfit
If you have defined a HABTM relationship your joining table should be links_users (i.e. the tables are in alphabetical order). Jeremy Burns Class Outfit http://www.classoutfit.com On 21 Jul 2011, at 16:26, localhost wrote: > Hi everyone, > > I have being trying to solve this for t

HABTM again!

2011-07-21 Thread localhost
Hi everyone, I have being trying to solve this for the last 4 hours with no luck. basically I have the following tables users links users_links Basically I'm trying to get the below query to run using find('all') and paginate (I'm running this inside UserController) SELECT Links.id,Links.Title

Re: MongoDB and HABTM

2011-07-19 Thread LordG
Ok, looking at the Mongo DB source code, it doesn't do any association queries. So i'm written a behavior to solve it. On Jul 18, 4:55 pm, LordG wrote: > Hello Bakers, > > I'm busy testing Models with MongoDB. I have two Models: Recipe and > Tag. > > class Recipe extends AppModel { >     var $nam

MongoDB and HABTM

2011-07-18 Thread LordG
Hello Bakers, I'm busy testing Models with MongoDB. I have two Models: Recipe and Tag. class Recipe extends AppModel { var $name = 'Recipe'; var $mongoSchema = array( 'name' => array('type' => 'string'), 'description' => array('type' => 'string'),

HABTM delete ignoring conditions definition

2011-07-07 Thread Lalas
Is CAKEPHP developer team planning to correct/adjust the _deleteLinks function in the cake\libs\model\model.php ? It ignores the conditions definition declared in the model. -- Original code: function _deleteLinks($id) { foreach ($this->hasAndBelongsToMany as $assoc => $data) {

Re: Multi Habtm Pagination

2011-06-29 Thread Johan
You can either add a JOIN [1] query for each HABTM association you want to filter on the pagination find, or BIND [2] the join table models (ProductsCategory and ProductsColor) to the Product model as HasOne associations before doing the pagination. Both would require to specify that the join must

Multi Habtm Pagination

2011-06-29 Thread Cengiz Eselioglu
Hi. I would like to paging products with multi Habtm. My tables: products categories colors And HABTM connections Product HABTM Categories products_categories Product belongsTo Color How do I make a query like the following? (width : Habtm Pagination) Category.id = 3 and Color.id=4 all

Re: habtm

2011-06-25 Thread Prabha Vathi
rst does a count query ... > > > Andras Kende > http://www.kende.com > > > On Jun 25, 2011, at 3:14 AM, Prabha Vathi wrote: > > Hi, > > I m not able to get good example for habtm. > I tried something. > $this->Post->unbindMode

Re: habtm

2011-06-25 Thread Andras Kende
bha Vathi wrote: > Hi, > > I m not able to get good example for habtm. > I tried something. > $this->Post->unbindModel(array('hasAndBelongsToMany'=>array('Tag'))); > $this->Post->bindModel( > array( > 

Re: habtm

2011-06-25 Thread Prabha Vathi
Hi, I m not able to get good example for habtm. I tried something. $this->Post->unbindModel(array('hasAndBelongsToMany'=>array('Tag'))); $this->Post->bindModel( array( 'hasOne'=>array( '

Re: habtm

2011-06-24 Thread Master Ram...!
HI you can solve this problem usign "custom query pagination". you can search in google you will get many examples. On Fri, Jun 24, 2011 at 10:02 PM, Prabha Vathi wrote: > Hi, > > In tagscontroller, > $this->paginate = array('conditions' => array('Post.status' => > 'active','Tag.tag_machine_

Re: habtm

2011-06-24 Thread Prabha Vathi
Any Help Please? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@google

habtm

2011-06-24 Thread Prabha Vathi
Hi, In tagscontroller, $this->paginate = array('conditions' => array('Post.status' => 'active','Tag.tag_machine_value' => $name),'limit' => 3); $posts = $this->paginate('Post'); $this->set(compact('posts')); Tag and Post model have hasAndBelongsToMany relation. I am getting Unknown column 'Tag.

Re: Validating HABTM

2011-06-15 Thread nachopitt
You should check this: http://bakery.cakephp.org/articles/nachopitt/2010/07/01/habtm-validatable-behavior On 15 jun, 08:24, Shaz wrote: > I haven't actually made models for the Join table - I don't think you > need to for a HABTM relationship > > On Jun 15, 1:41

Re: Validating HABTM

2011-06-15 Thread Shaz
I haven't actually made models for the Join table - I don't think you need to for a HABTM relationship On Jun 15, 1:41 pm, Rob Maurer wrote: > Interesting. What would happen if you put the validation in the model > for the join table? > > On Jun 14, 3:17 pm, Shaz wrot

Re: Validating HABTM

2011-06-15 Thread Rob Maurer
t; > > > > > Write the Validation Rule in Language Model instead of User Model > > > On Jun 14, 9:56 pm, Shaz wrote: > > > > I have User HABTM Language, and i want to ensure during a User add / > > > edit they choose a minimum of one language

Re: Validating HABTM

2011-06-14 Thread Shaz
that validation; where I only want the users to... Thanks! On Jun 14, 8:14 pm, hunny wrote: > Write the Validation Rule in Language Model instead of User Model > > On Jun 14, 9:56 pm, Shaz wrote: > > > > > > > > > I have User HABTM Language, and i want to ensure

Re: Validating HABTM

2011-06-14 Thread hunny
Write the Validation Rule in Language Model instead of User Model On Jun 14, 9:56 pm, Shaz wrote: > I have User HABTM Language, and i want to ensure during a User add / > edit they choose a minimum of one language, upto a maximum of 3. In > the user model, for $validate I've tried:

Validating HABTM

2011-06-14 Thread Shaz
I have User HABTM Language, and i want to ensure during a User add / edit they choose a minimum of one language, upto a maximum of 3. In the user model, for $validate I've tried: 'Language' => array( 'multiple' => array(

HABTM relationship don't save with Char PK

2011-06-13 Thread jorge1209
Hi, I'm using for my user table, username like PK and I have a HABTM relationship between user and messages, but when I create a message, the table messages_recipients is empty :( any help?? best regards, Jorge -- View this message in context: http://cakephp.1045679.n5.nabble.com/

HABTM Pagination

2011-05-30 Thread Shaz
I have the following relationships (habtm both ways): User HABTM Groups User HABTM Events User HABTM Locations So for example - I want to get users that belong to groupA, groupB and locationX and paginate the results - whats the best way of implementing it? I'm trying to avoid using bind

CakePHP 1.3 HABTM model problem

2011-05-26 Thread Lobo
Hi everyone, I have a problem when using CakePHP HABTM. I have the following models. class Repositorio extends AppModel{ var $name="Repositorio"; var $hasAndBelongsToMany = array( 'Sesion' => array( 'joinTab

Miles J - Uploader plugin - issues with habtm?

2011-05-25 Thread designv...@gmail.com
Hi there, Has anyone noticed any issues with the Miles J Uploader pluign (http:// milesj.me/code/cakephp/uploader) when used in forms that have HABTM elements? If I comment out the the habtm field the uploader works like a charm, as soon is its present though it fails to upload the files return

Re: HABTM pagination

2011-05-06 Thread Dee Johnson
Not sure if you read the question fully or just didnt understand it but I have already read ALL of that and frankly it is irrelevant. :) My issue is not covered anywhere in the cake docs as i have seen. My problem is similar to this guy and I am about to give this a whirl. http://cakephp.10456

Re: HABTM pagination

2011-05-06 Thread Tilen Majerle
http://book.cakephp.org/view/1231/Pagination read this :) -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/5/6 Dee Johnson > Hi guys, I would like to make a > > $this->MODEL->find call but would only like to bring back the items related > to that query and paginate the results. > > I tried

HABTM pagination

2011-05-06 Thread Dee Johnson
Hi guys, I would like to make a $this->MODEL->find call but would only like to bring back the items related to that query and paginate the results. I tried $this->paginate('Model', ('model.field' => 'value'); and then looped through the results but it looses the pagination on the related data

Paginating HABTM related results

2011-05-05 Thread Dee Johnson
Hi guys, Im having a small issue here. I have a model1 that HABTM model2 before I send the results to the view via a set, I run a foreach loop grab the first bit of results and then another to get to the associated data. the data array at that point (associated data only is being sent to

Re: Query with conditions in HABTM models

2011-04-30 Thread stas kim
ally every record except few latest uncategorized posts. in the long run those 3 lines of code will crush your server. perhaps you should look into habtm countercache. although it is not implemented for habtm as core feature. i've come across some articles with workarounds do that and it will c

Re: Query with conditions in HABTM models

2011-04-29 Thread davidhc
Ignore my previous message... I have solved it with this http://bin.cakephp.org/view/471586323 Thank you again, cricket :D David. On 29 abr, 10:17, davidhc wrote: > Only one more doubt... > > Could I use the native cakephp paginator with this model function? -- Our newest site for the communi

Re: Query with conditions in HABTM models

2011-04-29 Thread davidhc
Only one more doubt... Could I use the native cakephp paginator with this model function? Thanx! On 29 abr, 10:13, davidhc wrote: > Thank you very much, cricket! > > I have change your code: > $ids = Set::extract($this->PostCategory->find('all'), > '{n}.PostCategory.post_id'); > with: > $ids =

Re: Query with conditions in HABTM models

2011-04-29 Thread davidhc
ine :) Thank you! David. On 28 abr, 21:22, cricket wrote: > On Thu, Apr 28, 2011 at 12:31 PM, david hc wrote: > > Hello, > > I have a table posts related with table categories with de habtm table > > posts_categories. > > > posts.id > > categories.id >

Re: Query with conditions in HABTM models

2011-04-28 Thread cricket
On Thu, Apr 28, 2011 at 12:31 PM, david hc wrote: > Hello, > I have a table posts related with table categories with de habtm table > posts_categories. > > posts.id > categories.id > posts_categories.post_id > posts_categories.category_id > > I'm trying to g

Query with conditions in HABTM models

2011-04-28 Thread david hc
Hello, I have a table posts related with table categories with de habtm table posts_categories. posts.id categories.id posts_categories.post_id posts_categories.category_id I'm trying to get all the records WITHOUT category (because I have posts taken from RSS and not categorized yet). My

saving HABTM data with constructing my own array data

2011-04-25 Thread HK
I wanted to save a HABTM model but without using a regular form. Consider Entity1 HABTM Entity2, so we have a DB table for entity1, one for entity2 and one like entity1_entity2. I construct my own array like: [Entity1] => (field1, field2) [Entity2] => ( [0] => (field1, field2) [1] =

Re: updating habtm data with empty data (delete existing associations)

2011-04-24 Thread Tonu Tusk
Hi guys - any ideas? Am I doing this wrong, or is this just inconsistent behaviour and I should raise a ticket? cheers On Apr 22, 7:26 pm, Tonu Tusk wrote: > Hi there ... > > so let's say I have > > Cake habtm Ingredient > > and > > Ingredient habmt Cake &g

updating habtm data with empty data (delete existing associations)

2011-04-22 Thread Tonu Tusk
Hi there ... so let's say I have Cake habtm Ingredient and Ingredient habmt Cake If I was to prep $data such as [Cake][id] => 1 [Ingredient] => array(1, 2, 3) and did a Cake->save($data) this would delete any existing associating records in the join table between these

<    1   2   3   4   5   6   7   8   9   10   >