Re: HABTM problem for help

2011-03-06 Thread Ekin Han
Hi Stephen, Thank you very much for your kindly help. 2011/3/5 Stephen step...@ninjacodermonkey.co.uk Hi There From the cookbook: *With HABTM, you need to set the ID of the associated model in your data array. We'll build a form that creates a new tag and associates it on the fly with

HABTM problem for help

2011-03-05 Thread Ekin Han
Hi all, I have such a problem about HABTM. I have 3 tables, users table, bugs table and bugs_users table. The relation ship between users and bugs are just like below: users HABTM bugs bugs HABTM users Now I write a method in Bugs controller which name add() just like below function add(){

Re: HABTM problem for help

2011-03-05 Thread Stephen
Hi There From the cookbook: *With HABTM, you need to set the ID of the associated model in your data array. We'll build a form that creates a new tag and associates it on the fly with some recipe.* [1] Try doing User.id not User.username [1]

any body please help me with HABTM problem, please...

2011-02-03 Thread Tan Cheng
Hi, everyone, I am a newbie to cakephp, I am learning the HABTM, and try to see the post tag example working with the $scaffold. I have added the $hasAndBelongsToMany in both model files, but when I open the /blog/posts/add, I can never see the tags with the scaffolding. So frustrating... I

Re: Quick habtm problem

2010-04-15 Thread Blackbit
How about using WITH in the Judge-Model? Is this a good way to do it? class Judges extends AppModel { var $name = Judge; var $hasAndBelongsToMany = array(MediaSegments = array(with = JudgesMediaSegments)); } On 15 Apr., 02:37, Bryan Paddock bryanpadd...@gmail.com wrote: Ah! Thank you!

Quick habtm problem

2010-04-14 Thread Bryan Paddock
Hey all, Going a bit crazy here I think I need a break from this. Anyways, I have the following tables + relationships Judges MediaSegments (a category that the judge is selected to judge) JudgesMediaSegments (contains judge_id and media_segment_id) How would I find all the judges that belong

Re: Quick habtm problem

2010-04-14 Thread Jeremy Burns
Are you using Containable behaviour? You should be! Try this...(typed without testing - so go easy on me if it's wrong!)... From the MediaSegment controller: $this-MediaSegment-find( 'all', array( 'contain' = array( 'Judge'

Re: Quick habtm problem

2010-04-14 Thread Bryan Paddock
Ah! Thank you! After a while of tinkering with your code I realised I had the $actsAs in the controller and not the model :( Works like a charm. I've modified all of my code now to use containable behaviour. Gone with recursive = -1. On Wed, Apr 14, 2010 at 3:45 PM, Jeremy Burns

Re: HABTM problem...

2009-10-27 Thread WebbedIT
Contain does do extra queries and then merges arrays back together. It's great for certain situations and not so great for others. I particularly like to use it when viewing records and associated data, but I'm not so keen within indexes/lists of data. Bind and unbind allow you to force joins

Re: HABTM problem...

2009-10-25 Thread WebbedIT
Try using contain and doing a $result = $this-Playlist-find('first', array( 'conditions'=array('Playlist.id'=$id), 'contain'=array('Song'=array('Artist','Album')) )); Then do an echo debug($result); to see what it's fetched and how the array is structured.

Re: HABTM problem...

2009-10-25 Thread jayarjo
I beware of using contain, 'cause I don't understand how it works yet. I know that at least some times it runs multiple queries to achieve it's goal. Thanks for the tip though. After fighting with that thing for some time I did some unbind/bind models. And got the result with single query at

HABTM problem...

2009-10-24 Thread jayarjo
Let's say I've got table Playlists and table Songs (this one has it's own associations with Artists, Albums, etc.) that obvously got HABTM association (all tables are named properly, according to Cake conventions). Now the question (probably it's very dumb, sorry :) I got HABTM association

Re: HABTM problem...

2009-10-24 Thread jayarjo
I will rephrase a bit. As I said I have table Playlists and table Songs (this one has it's own associations with Artists, Albums tables, etc.) that obviously got HABTM association (all tables are named properly, according to Cake conventions). Now, how do I retrieve all songs, with all the

find with HABTM problem

2009-09-25 Thread Wladiston Paiva
hi peoples, i have two models is cakephp: class Pessoa extends AppModel { var $name = 'Pessoa'; var $primaryKey = 'codigo'; var $hasAndBelongsToMany = array( 'Areainteresse' = array( 'className'= 'Areainteresse',

Re: find with HABTM problem

2009-09-25 Thread brian
What does the find() code look like? It's possible that the problem is with your unconventional column names. It might work better if you use, eg. 'areainteresse_pessoa' for the join table and 'pessoa_id' for the key. Or it might be something else. On Fri, Sep 25, 2009 at 11:30 AM, Wladiston

Re: find with HABTM problem

2009-09-25 Thread Wladiston Paiva
unfortunately not always possible. because the database already exists. I am only deploying the system in PHP (currently Delphi). and the base is in Firebird. I had problems with the Auth component because of the Firebird, I believe the problem is the integration of the cake with the firebird. I

Containable, bindModel and HABTM problem

2009-09-15 Thread Ponch316
Hello, I have a problem with a couple of models that share a HABTM relationship. I've tried two different approaches, but none provide the desired result. Here are they both, I hope you can help me to fix either of them to get the array I need. I'm using the good old Post hasAndBelongsToMany

HABTM problem

2009-08-18 Thread Ace
I have standard users table. Every user can have many accounts (account is a group of permissions, like a role) and every account can be linked to many users. Relation is HABTM as you can see. When I call: $accounts=$this-User-find('first', array('conditions' = array ('User.user_id' = 1))); i

HABTM - problem when reading data for non-unique keys

2009-05-31 Thread BlueC
Here's my problem: If the foreign key in the HABTM join table isn't unique and could therefore return multiple matching records, all the records should be part of the returned dataset. The way it works now, only the first record is returned and the others are skipped. Simple example: Model

Re: HABTM problem

2009-02-22 Thread ykyuen
it is clear now thanks for your help :-) -- View this message in context: http://n2.nabble.com/HABTM-problem-tp2363919p2367984.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you

HABTM problem

2009-02-21 Thread ykyuen
the name and family name such that one tag_id is mapped to one name to solve this problem. But I just wanna know whether it is possible for one key to be mapped with more than one values. Thanks very much for your help.:-) kit -- View this message in context: http://n2.nabble.com/HABTM-problem

Re: HABTM problem

2009-02-21 Thread brian
here my question comes: as more ppl are added in the tags table i added another column tag_id namefamilyname -- 1 DavidBeckham 2 John Terry 3 Christano Ronaldo 4

Re: Strange habtm problem - saving in other tables

2008-05-08 Thread largon
If I comment out other habtm relationships, leaving only var $hasAndBelongsToMany = array( 'HasAsFriend' = array( 'className' = 'User', 'joinTable' = 'friends', 'foreignKey' = 'user_id',

Re: Strange habtm problem - saving in other tables

2008-05-08 Thread largon
I added some logging just to make sure the relationships are unbound: $this-User-unbindAll(array('hasAndBelongsToMany' = array('HasAsFriend'))); $this-log(current habtm: . print_r($this-User- hasAndBelongsToMany, true)); The error log reads: 2008-05-08 17:03:49 Error:

Re: Strange habtm problem - saving in other tables

2008-05-08 Thread largon
For anybody who's following this thread, or had the same problem, or dived in during a google: This seems like a bug mentioned at https://trac.cakephp.org/ticket/4558 After adding a unset($newValues) as the ticket mentions the problem goes away. Thanks all! On May 8, 5:08 pm, largon [EMAIL

Strange habtm problem - saving in other tables

2008-05-07 Thread largon
Hi, I'm on a project that users can add other users as friends, families, or block them. So I've set up some habtm behaviors for that. The tables (friends, families, blocks) look very similar, all with (user_id, friend_id) or (user_id, family_id) as keys. But when I save a data, like calling:

Re: Yet another HABTM problem with self-referencing model (var useTable)

2008-04-04 Thread dizz
I was just having the same problem, used your method and it's working fine now. On Mar 30, 9:36 pm, ste.ve [EMAIL PROTECTED] wrote: To visualize it better, these are my example Model definitions WORKS: class Tag extends AppModel {         var $hasAndBelongsToMany = array(                

Re: Yet another HABTM problem with self-referencing model (var useTable)

2008-04-04 Thread grigri
You just need to change the alias : class Tag extends AppModel { var $hasAndBelongsToMany = array( 'RelatedTag' = array('className' = 'Tag') ); } In your resultset the `Tag` key will now refer to the main tag and the `RelatedTag` will contain the related tags. Of course you can change

Yet another HABTM problem with self-referencing model (var useTable)

2008-03-30 Thread ste.ve
I have a Model (Model_1) which is related to itself by a second model (Model_2) by a HABTM relation. Model_2 uses a custom table (var $usetable = model_1) The problem: When I make a find call on Model_1, it returns correctly the row for itself, and the correct number of rows for Model_2, BUT all

Re: Yet another HABTM problem with self-referencing model (var useTable)

2008-03-30 Thread ste.ve
To visualize it better, these are my example Model definitions WORKS: class Tag extends AppModel { var $hasAndBelongsToMany = array( 'Tag2' = array( 'foreignKey' = 'tag_id',

Re: HABTM problem - Underscore in primary key name?

2007-11-21 Thread Action
Nvm, fixed. Was searching the google groups for the wrong term. On Nov 21, 12:55 pm, Action [EMAIL PROTECTED] wrote: I need to set up a HABTM association between two tables: users and teams. The problem I'm having is that the primary key in the users table is called user_id, not id. (I am

HABTM problem - Underscore in primary key name?

2007-11-21 Thread Action
I need to set up a HABTM association between two tables: users and teams. The problem I'm having is that the primary key in the users table is called user_id, not id. (I am not allowed to change this). How do I set up my join table and association so it associates Team.id with User.user_id, not

Re: HABTM problem - Underscore in primary key name?

2007-11-21 Thread DJ Spark
if you did check the manual, in 'models' chapter, you find about model variables: http://manual.cakephp.org/chapter/models $primaryKey If this model relates to a database table, and the table's primary key is not named 'id', use this variable to tell Cake the name of the primary key.

Re: habtm problem

2007-11-20 Thread AD7six
On Nov 20, 7:24 am, Dianne van Dulken [EMAIL PROTECTED] wrote: Thanks for that Yolabingo. It turned out I was making it all a bit too difficult for myself, so I'll put the solution here in case anyone else is having the same problem. Same as above except what I had to do before save is

Re: habtm problem

2007-11-19 Thread Dianne van Dulken
Thanks for that Yolabingo. It turned out I was making it all a bit too difficult for myself, so I'll put the solution here in case anyone else is having the same problem. Same as above except what I had to do before save is to force the ['articles']['articles'] values to be my array. So

Re: habtm problem

2007-11-14 Thread yolabingo
On Nov 12, 5:35 pm, Dianne van Dulken [EMAIL PROTECTED] wrote: function beforeSave() { $articles = explode(,, $_POST[data]['Teaser'][articles]); $this-Teaser-habtmAdd('Article', $this-data['Teaser']['id'], $articles); return parent::beforeSave(); //return

HABTM problem similar to described in manual's model's last section

2006-10-03 Thread Ahsan
hi, its ahsan. I am new to cakephp , but old to php :-) In the last section of the manual 's model description .. its described about the details of HABTM association between posts and tags.. the scenario presented there in last example is to associate a newly created post with a relevant tags,

Re: HABTM problem similar to described in manual's model's last section

2006-10-03 Thread andru
Generally if you're getting undefined variable it's because you haven't set the variable for the view to access. It depends what's on line 31 in your add.thtml file, but I'm guessing it's: $html-selectTag('Product/Product',$products) In which case you just need to set the $products variable in