Re: Correct model associations

2015-02-18 Thread gt0p
I sorted it out by using the HasMany thorough relation and by correcting the $data feed. On Friday, February 6, 2015 at 8:46:08 PM UTC, gt0p wrote: > > I am trying to bind 3 tables and I am having problems with proper > relations. > Table users (pk id), books (pk id), users_books (user_id, book

Re: Correct model associations

2015-02-18 Thread gt0p
I already missed one valid model association - has many through, and that solved my issue. Thanks anyway for the reply! On Monday, February 9, 2015 at 5:25:58 PM UTC, John Andersen wrote: > > Assuming you are using CakePHP 2.x > > It is a good idea to define a primary key in your HABTM table - in

Re: Correct model associations

2015-02-09 Thread John Andersen
Assuming you are using CakePHP 2.x It is a good idea to define a primary key in your HABTM table - in the books_users table (name should be alphabetic order, but you can deviate). Thus your table definition is: books_users id, book_id, user_id What is your comment table reflecting? 1) comments

Correct model associations

2015-02-08 Thread gt0p
I am trying to bind 3 tables and I am having problems with proper relations. Table users (pk id), books (pk id), users_books (user_id, book_id), comments (pk and foreign key book_id, user_id -> with reference to users_books) Here are the models: Book public $hasAndBelongsToMany = array(

Re: Bake and model associations

2014-04-17 Thread Tom Glare
uot; to reference parts.id. All now fine! -- View this message in context: http://cakephp.1045679.n5.nabble.com/Bake-and-model-associations-tp5717978p5717979.html Sent from the CakePHP mailing list archive at Nabble.com. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http:

RE: Help with Model associations and find

2013-09-06 Thread Nikki McMahon
egroups.com [mailto:cake-php@googlegroups.com] On Behalf Of lowpass Sent: 06 September 2013 01:51 AM To: cake-php@googlegroups.com Subject: Re: Help with Model associations and find If I understand correctly, you want the latest DataImport record, and all of its associated ClientData records,

RE: Help with Model associations and find

2013-09-06 Thread Nikki McMahon
'contain' => array( 'TelemetryData' => array( 'Hospital' => array( 'Province' ) ) ), 'recursive' => 3 ) ) Thanks for the help! From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Beha

Re: Help with Model associations and find

2013-09-05 Thread lowpass
;]['Province']['id'] = 9; > ClientData[1]['Hospital']['Province']['name'] = 'Gauteng'; > ClientData[2]['id'] = 6; > ClientData[2]['name'] = 'Client Name 2'; > ClientData[2]['DataImport'][&#x

RE: Help with Model associations and find

2013-09-04 Thread Nikki McMahon
x27;Hospital']['Province']['name'] = 'Eastern Cape'; I'm not sure if this helps at all? I basically loop through ClientData after pulling this, adjust some values according to algorithms and then print it out into a table. In that table I need to print the P

Re: Help with Model associations and find

2013-09-04 Thread Anja Liebermann
y first complex db design within the framework. > > I know how to do this in mySQL, but cannot figure out how to use Cake's > Model associations and find method to get it done. - All associations are > set up in the Models already. > > I have a table 'ClientData

Help with Model associations and find

2013-09-03 Thread Nif
use Cake's Model associations and find method to get it done. - All associations are set up in the Models already. I have a table 'ClientData'. It has foreign keys to 2 other tables, Hospital and DataImport. This is a manyToOne relationship (I think - basically, many ClientData&#x

Re: Form helper not adding "required" class to fields from deep model associations

2013-05-20 Thread Alex Bovey
Anyone? :) On Fri, May 17, 2013 at 4:04 PM, Alex Bovey wrote: > Hi all, > > In my Cake 2.3 app I'm using saveAll($this->request->data, array('deep' => > true)) to save deep model associations and the validation is working fine. > My input fields for any

Form helper not adding "required" class to fields from deep model associations

2013-05-17 Thread Alex Bovey
Hi all, In my Cake 2.3 app I'm using saveAll($this->request->data, array('deep' => true)) to save deep model associations and the validation is working fine. My input fields for any deeply associated models have the error class applied if I try to submit the form having l

Re: Trouble with model associations and query.

2012-12-10 Thread MDay
I seem to have resolved this, but I don't think it's the most efficient query: public function getStudents(){ $userId = $this->Auth->user('id'); $endusers = $this->RoleUser->findAllByuser_id($userId, array('RoleUser.enduserid','RoleUser.user_id')); //Get the enduserid's for all the roles I h

Re: Trouble with model associations and query.

2012-12-09 Thread lowpass
On Sun, Dec 9, 2012 at 2:30 PM, Md wrote: > > array ('RoleUser.id = ' => $userId))); //this is the current logged in user RolesUser -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed t

Trouble with model associations and query.

2012-12-09 Thread Md
I am having trouble returning a query. I have the following setup Users - users class of all users in the system. Roles - roles class with a set of available roles. E.g. teacher, student, tutor RoleUsers - a mapping table between users and roles as a single user can have multiple roles. My U

Scaffolded Form Input for Model Associations

2012-12-01 Thread Shawn Chin
After linking two models together with, for instance, using the $hasMany and $belongsTo definitions should I expect to see either a multi-select form input element in the add and edit scaffolded views for the model with the $hasMany definition? I would expect to get something in there but I don

New video tutorial: CakePHP basics part 4 - Model Associations

2012-08-23 Thread frederikjacques
Hi cake lovers, I've just uploaded part 4 of my cakePHP basics tutorial series. In this one I'll explain how you can create associations in your models to get associated data from other models when you retrieve data. http://blog.the-nerd.be/2012/08/cakephp-basics-tutorial-part-4/ Hope you like

Re: Model associations

2012-08-10 Thread André Luis
cricket, thanks for the answear, but it´s not exactly this... I have a menu wich is generated dinamically in ALL pages of the site, so it´s a part of the layout and the categories information needs to be in all pages. Em sexta-feira, 10 de agosto de 2012 00h23min04s UTC-3, cricket escreveu: > >

Re: Model associations

2012-08-10 Thread André Luis
Yes i do... I resolved the problem using requestAction, but i know that´s not correct. Em quinta-feira, 9 de agosto de 2012 17h28min29s UTC-3, Mark Wratten escreveu: > > Do you have var $belongsTo = array('Category', 'Product'); in your > CatProduct model? > > On Thursday, August 9, 2012 10:43:

Re: Model associations

2012-08-09 Thread lowpass
I'm not sure I follow all of that but I think what you want is a list of all Categories for the main page, and all Products for a given Category. If that's the case, I would set the main page as CategoryController::index(). This is from one of my projects: Router::connect( '/catalog',

Re: Model associations

2012-08-09 Thread Mark Wratten
Do you have var $belongsTo = array('Category', 'Product'); in your CatProduct model? On Thursday, August 9, 2012 10:43:43 AM UTC-4, André Luis wrote: > > Hi people, it´s me again! > > I am using a habtm relationship in my application, it works 100% fine... > But the Product menu is created dinam

Re: Model associations

2012-08-09 Thread André Luis
I´ve noticed that if i try do use the CatProduct in AppModel, the Product model becomes a AppModel object, and not a Product object anymore =( -- 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

Re: Model associations

2012-08-09 Thread André Luis
Now when i try to use the find all in appcontroller it seems to remove my behaviors for latter uses, what i am doing wrong?? -- 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 unsubscri

Model associations

2012-08-09 Thread André Luis
Hi people, it´s me again! I am using a habtm relationship in my application, it works 100% fine... But the Product menu is created dinamically with it´s Categories... so i have Product model and the Category model with habtm relationship between them. In AppController i have to set at beforeFi

Re: Model Associations Question

2012-06-27 Thread Mark Wratten
In you code you have 'className' => 'Bookings'. Shouldn't that be 'className' = 'Booking' ? You should also be able to shorten it to - var $belongsTo = array('Booking') as you are using booking_id as your foreign key. MArk On Wednesday, June 27, 2012 2:34:25 AM UTC-4, Sanfly wrote: > > Sorry,

Re: Model Associations Question

2012-06-27 Thread lowpass
This seems more like an HABTM association. A Booking can have/belong to many BookingDate and vice versa. I wonder, though, if it might be better to drop the BookingDate model and instead use date ranges. Something like date_from & date_to, or arrival & departure, in the bookings table. On Wed, Ju

Re: Model Associations Question

2012-06-26 Thread Sanfly
Sorry, I'll repost this - my database is Bookingdate not Bookingnight Hi Im having some trouble with a model association - yes, I have tried the manual! For each Booking I have, I can have many Bookingnights *Booking* Booking.id *Bookingdate* Bookingdate.id Bookingdate.booking_id In my

Model Associations Question

2012-06-26 Thread Sanfly
Hi Im having some trouble with a model association - yes, I have tried the manual! For each Booking I have, I can have many Bookingnights *Booking* Booking.id *Bookingnight* Bookingnight.id Bookingnight.booking_id In my Booking model, I am able to get all the associated Bookingnights wi

Re: Model Associations

2012-05-25 Thread Mike Griffin
On Thu, May 24, 2012 at 7:37 PM, hill180 wrote: > Solved:  But I don't know why.  This but this code puts the data where I > want it, and without the index error: > Good to hear, glad I could help. Mike -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check

Re: Model Associations

2012-05-24 Thread hill180
Solved: But I don't know why. This but this code puts the data where I want it, and without the index error: 'Contact' => array( 'className'=>'CONTACT', 'foreignKey' => false, 'finderQuery' => 'SELECT Account.AccountID as Contact__ACCOUNT_ID, contact.contact_full_name as Contact_

Re: Model Associations

2012-05-24 Thread hill180
Ok. Sorry for the last email. it made no sense: What I was trying to say is that I am getting *Notice* (8) : Undefined index: Contacts I copied the SQL Dumb (from the finderquery) in MSSQL Manager and it works. Just doing a debug($results) which is the results of the find query. Also it gets m

Re: Model Associations

2012-05-24 Thread hill180
Thank you so much. I think I am 99% there. Get the following error three times, (that is actually how many contacts are in the DB for the customer I was looking up. debug($results); *Notice* (8) : Undefined index: Contacts [* CORE\Cake\Model\Datasource\DboSource.php*, line *1412*] Code Context

Re: Model Associations

2012-05-24 Thread Mike Griffin
On Thu, May 24, 2012 at 3:14 PM, hill180 wrote: > Yes. > > As a disclaimer, I didn't write the original schema. > > Account_ID is for the systems account number (primary key) > Account is for the logical account number (used by the company) > > The Account Address table use the Account_ID as the f

Re: Model Associations

2012-05-24 Thread hill180
Yes. As a disclaimer, I didn't write the original schema. Account_ID is for the systems account number (primary key) Account is for the logical account number (used by the company) The Account Address table use the Account_ID as the foreign key, but the Contact Table uses the Account Number as t

Re: Model Associations

2012-05-24 Thread Mike Griffin
On Thu, May 24, 2012 at 1:50 AM, hill180 wrote: > AccountID = AccountID on the Account and the Address for the Account, no > problems here. > > > The problem is the contacts. > > The join is Contact.Account_id = Accounts.Account (not Account_ID) > > Error: SQLSTATE[42000]: [Microsoft][SQL Server N

Model Associations

2012-05-23 Thread hill180
*Cake *PHP 2. *public *$useTable = 'Accounts'; /** * Primary key field * * *@var* string */ *public *$primaryKey = 'AccountID'; *public *$hasMany = *array*( 'Address' => *array*( 'className' => 'AccountAddress', 'foreignKey' => 'AccountID', 'conditions' => '', 'fields' => '', 'ord

Re: Model Associations and Inserting through Associations

2012-05-05 Thread stork
If user is not logged in, then in Event form: echo $this->Form->input('Event.user_id', array('type' => 'hidden', 'value' => $user['User']['id'])); and in controller: $this->Event->create($this->request->data); if ($this->Event->save()) { ... Do not forget to use SecurityComponent in AppControl

Re: Model Associations and Inserting through Associations

2012-05-05 Thread Nate
I should have specified - the user doesn't necessarily have to be the logged in user. It could be any user, in which case $this->Auth->user('id') doesn't fit my needs. This is closer, I just need to figure out how to grab the user id from the users/view page. On Saturday, May 5, 2012 10:33:09 A

Re: Model Associations and Inserting through Associations

2012-05-05 Thread Nate
Trying to learn it through straight code before I dive into any console commands. One of the biggest reasons that I've put off using MVC is because I like to feel like I'm in control. Yes, probably dumb, but it makes more sense to my fragile brain. On Saturday, May 5, 2012 7:57:13 AM UTC-6, Mic

Re: Model Associations and Inserting through Associations

2012-05-05 Thread stork
$this->Event->create($this->request->data); $this->Event->set('user_id', $this->Auth->user('id')); if ($this->Event->save()) { ... -- 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

Re: Model Associations and Inserting through Associations

2012-05-05 Thread Michael Gaiser
You should take some time to learn how to use bake. It will setup the basics for you based on your database and will serve as a great example of how to do things. http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html There are many tutorials out there about setting it u

Model Associations and Inserting through Associations

2012-05-05 Thread Nate
MVC Beginner here - I have created a database with a USER table which hasMany EVENTS, and conversely have set the EVENTS belongsTo USER Here's my question: When I want to add an event from a user page (users/view), how do I automatically associate that event(event/add) with the user in the data

Re: multi-level Model associations behavior

2012-03-28 Thread Mike Griffin
On Tue, Mar 27, 2012 at 20:40, Augey Mikus wrote: > I am building an eLearning site in CakePHP that has models:  Course, > Test, Question, Answer, and others. > > Here are my associations: > > Course hasMany Test > Test belongsTo Course > Question belongsTo Test > Question hasMany Answer > Answer

Re: multi-level Model associations behavior

2012-03-27 Thread Loren Cole
you could replace $test = $this->Test->read(null, $id); $test['Question'] = $this->Test->Question->find('all'); //I added this line... with $test = $this->Test->find('first', array( 'conditions'=>array('id'=>$id), 'recursive'=2 )); the conditions array indicates which test records to get

multi-level Model associations behavior

2012-03-27 Thread Augey Mikus
I am building an eLearning site in CakePHP that has models: Course, Test, Question, Answer, and others. Here are my associations: Course hasMany Test Test belongsTo Course Question belongsTo Test Question hasMany Answer Answer belongsTo Question This model association works fine in most circums

Re: Cake 1.3 - Complicated Model associations

2011-12-04 Thread Toby G
I think I may have just answered my own question in writing that! If I use the 2 model & added a beforeSave to set the type when saving to set the 'type' field. & the condition on the relationship, then each of the ticket type models will not be able to see the transactions that relate to the othe

Cake 1.3 - Complicated Model associations

2011-12-04 Thread Toby G
Hi there, Am have a dilemma... I have a store that sells eTickets & physical tickets. Details of the sale of each type of ticket are stored in 2 tables (etickets & ptickets). I also have a table that stores details of when a user is directed off to PayPal to pay for their tickets (paypal_transa

Re: Conditions in model associations

2011-11-30 Thread euromark
rent "conditions array" for relations. > >> Personally, I think this should be addressed in 2.1 as a bugfix to be > >> fixed (if I add a global condition it should always be applied, no > >> matter what). > > >> As of right now you probably need to m

Re: Conditions in model associations

2011-11-29 Thread Jeremy Burns | Class Outfit
you probably need to manually join the conditions. >> >> On 29 Nov., 18:16, Jeremy Burns wrote: >> >> >> >> >> >> >> >>> I've noticed that if I have conditions on model associations, for >>> example: >&

Re: Conditions in model associations

2011-11-29 Thread euromark
Burns wrote: > > > > > > > > > I've noticed that if I have conditions on model associations, for > > example: > > > $hasMany = array( > >         'ActiveUser' => array( > >                 &#x

Re: Conditions in model associations

2011-11-29 Thread euromark
ht now you probably need to manually join the conditions. On 29 Nov., 18:16, Jeremy Burns wrote: > I've noticed that if I have conditions on model associations, for > example: > > $hasMany = array( >         'ActiveUser' => array( >                 '

Conditions in model associations

2011-11-29 Thread Jeremy Burns
I've noticed that if I have conditions on model associations, for example: $hasMany = array( 'ActiveUser' => array( 'className' => 'User', 'foreignKey' => 'group_id', 'c

Re: HELP! model associations lost after import

2011-11-17 Thread phpMagpie
Your first two examples will not work as models are not plural. http://book.cakephp.org/view/936/Importing-Controllers-Models-Components-Behaviors- HTH, Paul. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask

Re: HELP! model associations lost after import

2011-11-16 Thread Jeremy Burns | Class Outfit
Not sure what the issue is, but in general I'd recommend that you set recursive to -1 in your app_model and then use the Containable behaviour; it gives you total control and my well solve your issue (as well as bring other improvements). Jeremy Burns Class Outfit http://www.classoutfit.com O

HELP! model associations lost after import

2011-11-16 Thread billy
Due to a client's desire to have URLs that defy Cake logic, i have decided to use the pages controller to organize my app. most the site's functionality occurs from one page through ajax so i thought i'd use pages as the home base and access other controllers and models. so i decided to import the

Re: Model associations and combobox.

2011-04-16 Thread cricket
On Sat, Apr 16, 2011 at 2:34 PM, cricket wrote: > > public function add() > { >        if (!empty($this->data)) >        { >                // attempt to save >        } > >        $this->set( >                'fabricantes', >                $this->Carro->Fabricante->find('list') >        ); > } >

Re: Model associations and combobox.

2011-04-16 Thread cricket
On Fri, Apr 15, 2011 at 10:45 AM, Uriel Juliatti wrote: > Hey everybody > > I'd like to know how to display a list of > Manufacturers (associated with Cars) in a combobox when I create cars. > > My Mysql query returns it: > > SELECT `Carro`.`id`, `Carro`.`fabricante_id`, `Carro`.`nome`, > `Carro`.

Model associations and combobox.

2011-04-16 Thread Uriel Juliatti
Hey everybody I'd like to know how to display a list of Manufacturers (associated with Cars) in a combobox when I create cars. My Mysql query returns it: SELECT `Carro`.`id`, `Carro`.`fabricante_id`, `Carro`.`nome`, `Carro`.`modelo`, `Carro`.`blindado`, `Carro`.`cor`, `Carro`.`ano`, `Carro`.`pre

Re: How to properly use "conditions" in model associations

2011-03-02 Thread Eric Anderson
om day 1 like this so also would be curious to see > > > what others are doing in regards to the other params available for > > > relations. > > > > Good question :) > > > > K > > > > -Original Message- > > > From: cake-php@googlegr

Re: How to properly use "conditions" in model associations

2011-03-02 Thread euromark
o also would be curious to see > > what others are doing in regards to the other params available for > > relations. > > > Good question :) > > > K > > > -Original Message- > > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Beha

Re: How to properly use "conditions" in model associations

2011-03-02 Thread gremlin
ent: Wednesday, March 02, 2011 3:57 PM > To: CakePHP > Subject: How to properly use "conditions" in model associations > > Hi everyone, > > I'm wondering what is the 'proper' or 'suggested' way of using > "conditions" in model associa

RE: How to properly use "conditions" in model associations

2011-03-02 Thread Krissy Masters
ly use "conditions" in model associations Hi everyone, I'm wondering what is the 'proper' or 'suggested' way of using "conditions" in model associations. I'm using an Activity model to log activities performed throughout my app. I then use this table t

How to properly use "conditions" in model associations

2011-03-02 Thread Eric Anderson
Hi everyone, I'm wondering what is the 'proper' or 'suggested' way of using "conditions" in model associations. I'm using an Activity model to log activities performed throughout my app. I then use this table to output activity feed / notifications style s

Re: can you bypass model associations in a find

2011-01-05 Thread cricket
On Wed, Jan 5, 2011 at 9:44 AM, roundrightfarm wrote: > Thanks for your help.  Got it to work... but > can you please explain why this didn't work > > $orders = $this->Order->find('all', >                        array('conditions'=>array('Order.week_id'=>$week_id)), >                        array(

Re: can you bypass model associations in a find

2011-01-05 Thread roundrightfarm
Thanks for your help. Got it to work... but can you please explain why this didn't work $orders = $this->Order->find('all', array('conditions'=>array('Order.week_id'=>$week_id)), array('contain' => array('Box' => array('Item'))) );

Re: can you bypass model associations in a find

2011-01-05 Thread Jeremy Burns | Class Outfit
The Containable behaviour is your very best friend: http://book.cakephp.org/view/1323/Containable Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 5 Jan 2011, at 13:10, roundrightfarm wrote: > I'm having to do a find('all') with recursive = 2 to get at the da

can you bypass model associations in a find

2011-01-05 Thread roundrightfarm
I'm having to do a find('all') with recursive = 2 to get at the data I need in my array. Unfortunately using this level of recursion also pulls in a bunch of unneeded data, creating a monster array which is stretching the memory limits. Is there some syntax (perhaps involving 'fields') that will

Re: Newbie question - having trouble with baked model associations

2010-10-15 Thread Jeremy Burns | Class Outfit
See here: http://groups.google.com/group/cake-php/browse_thread/thread/7bfef9785d10d2d5 Jeremy Burns Class Outfit jeremybu...@classoutfit.com (t) +44 (0) 208 123 3822 (m) +44 (0) 7973 481949 Skype: jeremy_burns http://www.classoutfit.com On 15 Oct 2010, at 13:52, deafpanda wrote: > Hello, > >

Re: Newbie question - having trouble with baked model associations

2010-10-15 Thread Jeremy Burns | Class Outfit
See here: http://groups.google.com/group/cake-php/browse_thread/thread/7bfef9785d10d2d5 Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 15 Oct 2010, at 13:52, deafpanda wrote: > Hello, > > Sorry if this question is really stupid, I'm new to cake and I'm sur

Newbie question - having trouble with baked model associations

2010-10-15 Thread deafpanda
Hello, Sorry if this question is really stupid, I'm new to cake and I'm sure I'm missing something obvious but Google isn't helping me... I'm following the tutorials in the cakephp book, and am on to the ACL tutorial. I created all the tables and baked the models, controllers and views but when

Model Associations

2010-06-30 Thread Ed Propsner
Is there a best practice or rule of thumb to work from when defining model associations? It seems pretty cut and dry and there's not much that you can really mess up. I know this problem has been brought up here in the past but I'm still unable to find a solution after reviewing old

Re: Model associations problem

2010-06-17 Thread Jeremy Burns | Class Outfit
The results are perfectly correct for the code you are running; you are finding all Trackers. Your code: $this->set('trackers', $this->User->Tracker->find('all')); ... is saying "go to the User model, then leap out to the Tracker model and bring me back all Trackers". To filter the search, pa

Model associations problem

2010-06-17 Thread ryanl
I'm in the process of creating my first web application with CakePHP, however I've run into some problems. I'll just start with the code: class User extends AppModel { public $name = 'User'; public $belongsTo = 'Group'; public $hasMany = array( 'Tracker' =>

Re: Cake caching model associations?

2010-05-12 Thread
Oops, forgot that I also moved them into separate Plugins - fixed the problem now with a simple bit of common sense! Cheers! On May 12, 12:47 pm, "WoJo&Co" wrote: > Hi, > > Quick question about Cake and model associations. > > I had an association that worked fine

Cake caching model associations?

2010-05-12 Thread
Hi, Quick question about Cake and model associations. I had an association that worked fine: User hasOne UserAccount fk: UserAccount.user_id UserAccount belongsTo Club fk: UserAccount.club_id I have now changed this, so that User hasOne UserAccount fk: UserAccount.user_id UserAccount

Re: Model Associations - just feels wrong

2010-03-19 Thread TheHerk
Thanks for taking a look at that LunarDraco. At first, the database was going to be configured with no surrogate keys where there was a logical candidate key. At least for parent tables. Then I found out that cakephp does not support compound keys, so I had to abandon that plan. Also, I found out t

Re: Model Associations - just feels wrong

2010-03-19 Thread LunarDraco
The problem I see with your model is in your ZipLocation you have the code set to a PK. The Problem: It is often thought that a zipcode belongs to only one city. And that a city can have many zipcodes. There are no such rules in the postal system. One zip code could and often overlaps many city b

Re: Model Associations - just feels wrong

2010-03-19 Thread TheHerk
; > Thanks. > > On 17 mar, 23:41, TheHerk wrote: > > > > > Here is a link to a screenshot of a class diagram I am working on, > > with noted model associations. There are several relationships in the > > diagram that feel wrong to me. The one in the diagram that

Re: Model Associations - just feels wrong

2010-03-19 Thread Antônio Marco
Hi, TheKerk, morning! Can you post the models association's code here? Thanks. On 17 mar, 23:41, TheHerk wrote: > Here is a link to a screenshot of a class diagram I am working on, > with noted model associations. There are several relationships in the > diagram that feel wrong

Re: Model Associations - just feels wrong

2010-03-18 Thread Miles J
and you correctly, then you consider the ZipLocation to be > > > > the parent of the State? > > > > > My understanding of the situation is the reverse, one State may have > > > > one or more ZipLocations, so one ZipLocation belongs to one State. > > > > >

Re: Model Associations - just feels wrong

2010-03-18 Thread TheHerk
of the State? > > > > My understanding of the situation is the reverse, one State may have > > > one or more ZipLocations, so one ZipLocation belongs to one State. > > > > So your diagram looks correct with regard to the relationship between > > > ZipLocation an

Re: Model Associations - just feels wrong

2010-03-18 Thread Miles J
one State may have > > one or more ZipLocations, so one ZipLocation belongs to one State. > > > So your diagram looks correct with regard to the relationship between > > ZipLocation and State :) > > Enjoy, > >    John > > > On Mar 18, 4:41 am, TheHerk

Re: Model Associations - just feels wrong

2010-03-18 Thread TheHerk
n > ZipLocation and State :) > Enjoy, >    John > > On Mar 18, 4:41 am, TheHerk wrote: > > > > > Here is a link to a screenshot of a class diagram I am working on, > > with noted model associations. There are several relationships in the > > diagram that

Re: Model Associations - just feels wrong

2010-03-18 Thread John Andersen
between ZipLocation and State :) Enjoy, John On Mar 18, 4:41 am, TheHerk wrote: > Here is a link to a screenshot of a class diagram I am working on, > with noted model associations. There are several relationships in the > diagram that feel wrong to me. The one in the diagram that il

Model Associations - just feels wrong

2010-03-17 Thread TheHerk
Here is a link to a screenshot of a class diagram I am working on, with noted model associations. There are several relationships in the diagram that feel wrong to me. The one in the diagram that illustrates this is between ZipLocation and State. In this case, state is enumerated in its own table

Model associations causing problems in behaviors

2010-02-15 Thread DanCake
I have two associated models, Series (hasMany) and SeriesTitle (belongsTo) each use the Searchable behavior. While the association is active and I try to save to the SeriesTItle model, all behaviors break as for some reason $this->model contains the Series model rather than the SeriesTitle. This o

Model associations

2010-01-08 Thread Daniel S. Reichenbach
these textures there is a separate model name texture_info to track stats like gender of bounding radius of a texture. If a I understand the Cake way of doing model associations, I would have to change the models to rather look like: [code] [/code] Thus I'd move the texture ID's curr

Re: Complex model associations, pagination and containable

2009-10-08 Thread martinp
I've managed to get it working. The answer was simple, yet not obvious. In order to get these deep level associations working you need to add the association in the first model. In my case that's Model1 or CourseResult. This is how: var $belongsTo = array( 'Course' => arra

Model Associations on legacy tables with no primary keys

2009-09-28 Thread reesylou
I have a legacy database and I am unfotunately unable to change the table structure. I have the following tables: CODE scheduled_models (no primary key set, but should be model_id) model_idint(11) auto_increment model_name varchar(15) ... and other fields and: CODE schedule_dat

Model associations problem

2009-09-21 Thread Aivaras
Hey folks, There is this problem I am facing at the moment. Not sure how to solve it. So, my Gallery var $hasOne = array( 'MainPhoto' => array( 'className' => 'Upload', 'foreignKey' => false, 'fields' => array('MainPhoto.filename'),

Re: Complex model associations, pagination and containable

2009-09-13 Thread brian
I see what you mean. My eyes glazed over. :-) How about posting the output of debug($this->paginate) (after you've set the conditions)? On Sun, Sep 13, 2009 at 4:41 PM, martinp wrote: > > It's quite complicated as I have to deal with some craziness in the > form search form submission. I don't t

Re: Complex model associations, pagination and containable

2009-09-13 Thread martinp
It's quite complicated as I have to deal with some craziness in the form search form submission. I don't think this is the problem, but here's the function that sorts out the conditions: private function setPreConditions() { $preConditions = $this->postConditions($this->da

Re: Complex model associations, pagination and containable

2009-09-12 Thread brian
I missed Miles's post, also. I, too, think your $conditions looks strange. Can you post the actual code (not debug output)? On Fri, Sep 11, 2009 at 11:57 AM, martinp wrote: > > Hello > > Thanks for your replies. I thought I was watching this topic, but > wasn't aware that the discussion had conti

Re: Complex model associations, pagination and containable

2009-09-11 Thread martinp
Hello Thanks for your replies. I thought I was watching this topic, but wasn't aware that the discussion had continued without me! Brian - I think you've hit the nail on the head regarding my containment problem, but I still don't have it working. Miles J - I assure you they are all belongsTo as

Re: Complex model associations, pagination and containable

2009-09-04 Thread Miles J
Correct me if im wrong, but are you allowed to use $conditions the way he is? On top of that, I feel like were not seeing all the queries, all of those associations cant be belongsTo. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Complex model associations, pagination and containable

2009-09-04 Thread brian
On Fri, Sep 4, 2009 at 2:16 PM, Miles J wrote: > > But its in the where clause, so hes supplying it himself. > > LEFT JOIN `courses` AS `Course` ON > (`CourseResult`.`course_id` = `Course`.`id`) WHERE > `Course`.`course_type_id` = 1 AND `School`.`city` = 'London' AND > `School`.`country_id` = '225

Re: Complex model associations, pagination and containable

2009-09-04 Thread Miles J
But its in the where clause, so hes supplying it himself. LEFT JOIN `courses` AS `Course` ON (`CourseResult`.`course_id` = `Course`.`id`) WHERE `Course`.`course_type_id` = 1 AND `School`.`city` = 'London' AND `School`.`country_id` = '225' AND ((`CourseLevelMin`.`order` <= '1') OR (`Course`.`cours

Re: Complex model associations, pagination and containable

2009-09-04 Thread brian
On Fri, Sep 4, 2009 at 11:55 AM, Miles J wrote: > > No its not. > > Error: 1054: Unknown column 'School.city' in 'where clause' > > That means you dont have a column named city on your school table/ > model, thats not caused by the containment. It *appears* that way, yes. But remember that "Schoo

Re: Complex model associations, pagination and containable

2009-09-04 Thread Miles J
No its not. Error: 1054: Unknown column 'School.city' in 'where clause' That means you dont have a column named city on your school table/ model, thats not caused by the containment. On Sep 4, 1:12 am, martinp wrote: > Haven't I got MySQL errors because my model's aren't being contained? > > O

  1   2   >