Re: Model Association and Find

2012-01-09 Thread jeremyharris
Since HABTM data is constructed as separate SQL statements, and not a JOIN, you cannot add conditions to the query directly. There are ways to get the data you want, though. Check out the example in the book[1] or search Google for cakephp find habtm data 1:

Re: Model association, I've made it correctly???

2010-10-17 Thread euromark
you probably meant Type hasMany BooksUser... On 17 Okt., 22:17, Mariano C. mariano.calan...@gmail.com wrote: I'm studing model associations, I would know if i've understand it correctly: I have five tables: users, books, books_users, authors and types. users, authors and types just have PK

Re: Model association problem - not getting expected array using $hasMany and $belongsTo association

2010-10-12 Thread cricket
Everything appears to be correct. Try deleting any files in app/tmp/cache/models/ if you haven't already. And set debug to 2, both so the models won't be cached and so you can see what queries are being run. On Mon, Oct 11, 2010 at 2:04 PM, Ashwani Kumar ashwani.mail...@gmail.com wrote: Hi all!

Re: Model association through user_id

2010-03-17 Thread cricket
In User model: var $displayField = 'username'; Then find('list') will return an array as id = username On Mar 17, 8:50 pm, abocanegra aaronbocane...@gmail.com wrote: I am trying to learn more about associating through models. My current issue is that I am attempting to design the post add

Re: Model association through user_id

2010-03-17 Thread abocanegra
Thank you for the response. I was able to get it working finally by the following code int he postscontroller under the add function. $users = $this-Post-User-find('list', array('fields' = array('User.username'))); $this-set(compact('users')); Thanks On Mar 17, 7:27 pm, cricket

Re: Model Association 'chain'

2010-02-24 Thread John Andersen
Take a look in the CakePHP manual at the Containable behaviour, which will give you the possibility to specify how deep you want to go in your relationships when retrieving your data. http://book.cakephp.org/view/474/Containable Also it will make your life easier :) Enjoy, John On Feb 24,

Re: Model Association 'chain'

2010-02-24 Thread WebbedIT
In the case of viewing a record, Containable is very much your friend. Saves you so much time. If paginating deep associations, espcially if you want a condition on model 3 or 4, then you need to get your head around ad-hoc (forced) joins.

Re: Model Association via conditions fails!

2009-07-23 Thread lapinski
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ Lapinski ohneworte-2 wrote: Hello Together, I want to link two Models without using a Foreign Key, but using some Conditions instead. Here is my example: Model: - class Category extends AppModel {

Re: Model association problem

2009-07-17 Thread Zoran Kovac
Here are some of the table fields. it's the table USER, GROUPS and MEDICIANL DEVICE. In short relatons are: ser should be in one group and have many MedDevice, group should have one user, medicinal device should have only one user. CREATE TABLE IF NOT EXISTS `baza2`.`USER` ( `id` INT NOT NULL

Re: Model association problem

2009-07-17 Thread leop
The database table names ought to be plural, viz: MEDICINAL_DEVICES, USERS etc. Cake is intelligent enough to handle plurals such as COMPANIES (COMPANY). In the model definitions, the model will be the capitalised singular version of the tablename, e.g. User Foreign keys are singular, e.g.

Re: Model association problem

2009-07-17 Thread Carlos Lavin
Tables are supposed to be plural (users,groups,medicinal_devices) and the foreign keys singular(user_id,group_id...) Change it and give it another shot =) 2009/7/17 Zoran Kovac zoko2...@gmail.com Here are some of the table fields. it's the table USER, GROUPS and MEDICIANL DEVICE. In short

Re: Model association problem

2009-07-17 Thread Zoran Kovac
Aargh...name conventions, still not used to it. Thanks for the heads up, knew it had to be something obvoius. It always is ;)) Now it works like a charm. -- Zoran Kovac 091/ 588 6175 V.Gorica On Fri, Jul 17, 2009 at 9:53 AM, Carlos Lavin carloslavi...@gmail.comwrote: Tables are supposed to

Re: Model association problem

2009-07-16 Thread Carlos Gonzalez Lavin
Maybe if you described the tables' fields.. theres gotta be some convention breaking there 2009/7/16 Zoran Kovac zoko2...@gmail.com Hi! I'm having a dilema, maybe the better word is that I'm puzzled. The problem is when I'm baking models. The console doesn't detect relations between

Re: Model Association Not Creating Query Joins

2009-04-25 Thread James K
Start from the AccountAlert model rather than the Alert model. Use contain as well. $alert_ids = $this-AccountAlert-find ( 'all', array ( 'contain' = array(), 'conditions'= array ( 'AccountAlert.account_id' =

Re: Model Association Not Creating Query Joins

2009-04-25 Thread Rob Wilkerson
On Apr 25, 9:55 am, James K james.m.k...@gmail.com wrote: Start from the AccountAlert model rather than the Alert model. Use contain as well. $alert_ids = $this-AccountAlert-find (         'all',         array (                 'contain' = array(),                 'conditions'    =  

Re: Model Association Not Creating Query Joins

2009-04-24 Thread Walther
In cases like what you are looking at it tends to work a bit better if you rather do the find on the model you want to filter. Something like: $alert_ids = $this-Alert-AccountAlert-find ( 'all', array ( 'conditions'= array (

Re: Model association

2008-12-26 Thread MikeB
var $hasmany = array('People', 'Post', 'Tag); On Dec 26, 11:51 am, mona poojapinj...@gmail.com wrote: How to make association between three of four tables because i m fetching data on my table from three different tables --~--~-~--~~~---~--~~ You received this

Re: Model association

2008-09-17 Thread Luiz Poleto
You can create the column stock in the association table.In the form where you do the association, you can add a new field for the stock. At least that was what i understood from your question... Regards, Luiz Poleto 2008/9/17 VitillO [EMAIL PROTECTED] Hi, i have the following structure for

Re: Model association

2008-09-17 Thread Adam Royle
You can create a model for your habtm association so you can add extra fields, etc, using the with key. Something like this... class Product extends AppModel { ... var $hasAndBelongsToMany = array( 'Size' = array('className' = 'Size', 'with' = 'ProductsSize', // -- this here, class

Re: Model association

2008-09-17 Thread VitillO
Hi guys, thanks for your replies. Right now, im my 'add' view of products, im getting a multiple select for the sizes, where i can select which sizes are available for that particular product, thats fine. The problem is that i need a stock number for each of this available sizes, so a multiple

Re: Model association

2008-09-17 Thread teknoid
I explain how with work here, I think this should be good to get you started: http://teknoid.wordpress.com/2008/07/03/notes-on-cakephp-habtm-part-1-the-basics/ Also, just a hint... cake can easily create checkboxes for you (instead of multi-select). Just tell it to use 'multiple'='checkbox' in

Re: Model association

2008-09-17 Thread VitillO
Ok guys, it seems i have the data (extra field 'stock' in the association table) in $this-data when i edit a Product, something like this, so the association table is auto-modelized: [Size] = Array ( [0] = Array ( [id] = 2

Re: Model association question

2008-07-03 Thread John David Anderson
I always remember it like this: If a table contains a foreign key, it's like a little label that another object has put on it... i.e. it belongsTo something else. hth/fwiw, John On Jul 3, 2008, at 1:38 PM, Jonathan Snook wrote: A priority hasMany tasks. A task belongsTo a priority.

Re: Model association question

2008-07-03 Thread francky06l
@Jonathan, yes it always a bit confusing the hasOne (in Cake).. because a Task hasOne priority, no matter if this priority is shared .. but for cake it'a a belongsTo .. :-) Even after using for few months (years)... hasOne always make me think twice (actually I use it very rarely).. On Jul 3,

Re: Model Association Query....stumped

2008-02-08 Thread EchoChargen
I've done the following: Clipranking Model: function findClipByRank($site_id){ return $this-query(SELECT Clipranking.rank, Clipranking.site_id, Clipranking.required, Clip.id, Clip.name, Clip.length FROM cliprankings AS Clipranking, clips AS Clip WHERE Clipranking.site_id =

Re: Model Association without Foreign key (Cake 1.18)

2008-02-06 Thread Bo-oz
It's 1.19 btw... but think that won't mather much. On Feb 6, 10:16 am, Bo-oz [EMAIL PROTECTED] wrote: Hi, I would like to enrich a model with data from another model. However they are not directly related. The value that needs to be fetched from the other model lies within a certain

Re: Model Association without Foreign key (Cake 1.18)

2008-02-06 Thread Bo-oz
I was afraid of that... I've read some other reply's by you in another thread, and based on that, I was already expecting that this could not be done. Would be great functionality though. On Feb 6, 10:37 am, AD7six [EMAIL PROTECTED] wrote: On Feb 6, 10:23 am, Bo-oz [EMAIL PROTECTED] wrote:

Re: Model Association without Foreign key (Cake 1.18)

2008-02-06 Thread AD7six
On Feb 6, 10:23 am, Bo-oz [EMAIL PROTECTED] wrote: It's 1.19 btw... but think that won't mather much. I think you need (a v recent) 1.2 for that to work unless you do it yourself hth, AD --~--~-~--~~~---~--~~ You received this message because you are

Re: model association results

2007-12-26 Thread lordG
This does also tend to be related to my post on naming conventions in http://groups.google.com/group/cake-php/browse_thread/thread/35318b04d8a93144/fcffe0e17499f82c?lnk=stq=#fcffe0e17499f82c if the class name and the $name value are to be the same, why is this not the case with Controllers? Is

Re: Model Association 'limit' not working

2007-12-08 Thread zonium
Did you try turning on debug mode and see how the SQL statement looks like? Try running the sql statement manually and you should be able to track where the problem is. Zonium On Dec 7, 5:30 pm, sanderken [EMAIL PROTECTED] wrote: People looking for the answer to defining limit row in oracle

Re: Model Association 'limit' not working

2007-12-07 Thread sanderken
People looking for the answer to defining limit row in oracle : in the model , use the 'conditions' = ' WHERE ROWNUM = 3 ' option. Limit is the implementation in mySQL. Hope this helps someone... On 8 dec, 01:53, sanderken [EMAIL PROTECTED] wrote: Maybe I should mention I'm using

Re: Model Association 'limit' not working

2007-12-07 Thread sanderken
Maybe I should mention I'm using oracle for DBMS. On 7 dec, 21:54, sanderken [EMAIL PROTECTED] wrote: Hey, I defined a user (named Gebruiker in my native language ) model where when I call a $this-find() , needs to retrieve only a limited amount of related information. When I add the

Re: Model Association (again)

2006-10-24 Thread Ismael S. Kafeltz
Maybe this can help you: http://wiki.cakephp.org/docs:understanding_associations --~--~-~--~~~---~--~~ 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

Re: Model association issue

2006-09-13 Thread AD7six
Hi Brian, You can´t create 2 associations with the same name. You can't say a user HasOne Venue and User HABTM Venue - if you don´t give you associations unique names the data for both will get mixed together (with confusing results as you have seen). Let me clarify what that means before you

Re: Model association issue

2006-09-13 Thread Brian French
Thank you! That fixed my problem perfectly! AD7six wrote: Hi Brian, You can´t create 2 associations with the same name. You can't say a user HasOne Venue and User HABTM Venue - if you don´t give you associations unique names the data for both will get mixed together (with confusing results

Re: Model association issue

2006-09-12 Thread Brian French
Could someone help me with this? Brian French wrote: I should have elaborated more. When you view that link then go to view a particular user: http://www.myclubbersguide.com/users/view/6 The associations dont seem to be working and i am now getting a php error. (i have a view method in

Re: Model association issue

2006-09-11 Thread Brian French
bump Brian French wrote: I am having trouble associating the multiple models i have with each other. I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'. The 'User' also hasAndBelongsToMany of the same ones (like he can subscribe to them as well as be one/all of them). I am

Re: Model association issue

2006-09-11 Thread Chris Hartjes
On 9/8/06, Brian French [EMAIL PROTECTED] wrote: I am having trouble associating the multiple models i have with each other. I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'. The 'User' also hasAndBelongsToMany of the same ones (like he can subscribe to them as well as be

Re: Model association issue

2006-09-11 Thread Brian French
Scaffolding can display this for you, it's a great tool! You can view the output here: http://www.myclubbersguide.com/users It contains the queries being used as well as the print_r() of the object(s). The code for the models was in the first email/post in this thread. As far as i understand

Re: Model association issue

2006-09-11 Thread AD7six
Hi Brian, I took a peek at your link: I don´t quite understand what the problem is, can you elaborate? The sql at the foot of the page shows that sql queries are being executed for your associations. If you look at the user test you can see that there are results for each association type.

Re: Model association issue

2006-09-11 Thread Brian French
I should have elaborated more. When you view that link then go to view a particular user: http://www.myclubbersguide.com/users/view/6 The associations dont seem to be working and i am now getting a php error. (i have a view method in the users controller, but i commented it out so the

Re: Model association

2006-05-09 Thread roberts.sean
I'm having a similar problem simply trying to add comments to posts. I've tried to get a list of comments that would be associated with a single post by adding $this-set('comments', $this-Comment-findAll(WHERE post_id = '$id')); to the view() function under posts_controller.php but that line

Re: Model association

2006-05-09 Thread John Anderson
Gotta use model assocations - it makes this sort of thing so much nicer. http://manual.cakephp.org/chapter/6 Looks like your Comment belongsTo Post, and probably Post hasMany Comment. Give the manual a look, and let me know if you have questions on it. -- J On May 9, 2006, at 1:47 PM,

Re: Model association

2006-05-09 Thread roberts.sean
I read through the manual in one go last week, totally forgot I had to set up the associations myself. Now that I've done it I can't believe how simple it is. I'm REALLY starting to like this whole baking thing. Thanks John! --~--~-~--~~~---~--~~ You received