Re: HELP! model associations lost after import
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.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
HELP! model associations lost after import
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 relevant models. i have tried all three methods: $this-loadModel('Inventories'); $Inventories = ClassRegistry::init('Inventories'); App::import('Controller', 'Inventories'); $Inventories = new InventoriesController; Model seems to load fine but when i try to find some records: $(...)-find(all, array( 'conditions' = array('id' = '1'), 'recursive'=2) ); i only get results as if recursive had been -1 or as if there were no other associated models this happens no matter what level of recursive i put and when i load the model in regular controllers, i get an appropriate response. any ideas how i can change my pages controller to retrieve associated models like regular controllers? -- 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: HELP! model associations lost after import
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 On 16 Nov 2011, at 23:36, billy wrote: 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 relevant models. i have tried all three methods: $this-loadModel('Inventories'); $Inventories = ClassRegistry::init('Inventories'); App::import('Controller', 'Inventories'); $Inventories = new InventoriesController; Model seems to load fine but when i try to find some records: $(...)-find(all, array( 'conditions' = array('id' = '1'), 'recursive'=2) ); i only get results as if recursive had been -1 or as if there were no other associated models this happens no matter what level of recursive i put and when i load the model in regular controllers, i get an appropriate response. any ideas how i can change my pages controller to retrieve associated models like regular controllers? -- 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php -- 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Help with associations
I need some help with linking my database tables and models. I have: User Profile Post A User has many posts, one profile and many friends(other users). I want to display the users posts and the users friends posts on the profile. How should i build the database(like friendship between users) and the model associations? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help with associations
You need an additional information - who is friend with whom - so a new table users_users is born :) So your relationships will be: users hasMany posts users hasAndBelongsToMany users through users_users. And you have to find: 1) The current users post using users hasMany posts association. 2) The current users friends posts using both associations users hasAndBelongsToMany users (friends) hasMany posts For 2) you have to lookup recursive and unbindModel/bindModel. Enjoy, John On Apr 20, 2:34 am, Victorr victor.ry...@gmail.com wrote: I need some help with linking my database tables and models. I have: User Profile Post A User has many posts, one profile and many friends(other users). I want to display the users posts and the users friends posts on the profile. How should i build the database(like friendship between users) and the model associations? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Need Help with Associations
Hi, I have two tables, franchises and owners. The owners table has a foreign key to franchises called franchise_id. I've defined a $hasMany relationship between franchise and owners (ie. 1 franchise can have many owners). I've defined a $belongsTo relationship between owner and franchise (ie. an owner belongs to a franchise). Now, I'm trying to edit franchise and the associated owner information. However, I can't seem to access the owner information. Here is my franchises_controller.php function for edit: function edit($id = null) { if(empty($this-data['Franchise'])) { $this-Franchise-id = $id; $this-data = $this-Franchise-read(); } else { if($this-Franchise-save($this-data['Franchise'])) { $this-flash('Your franchise has been updated.', '/franchises/'); } } } Here is my edit.thtml file. Please note that I am confused as to how the data is pre-populated in the form and why can't I seem to get the owner associated data pre-populated? I'm also trying to print the $data array, with no success. h1Edit Franchise/h1 form action=?php echo $html-url('/franchises/edit') ? method=post ?php echo $html-hidden('Franchise/id'); ? pName: ?php echo $html-input('Franchise/name', array('size' = '40')) ?/p pOwner First Name: ?php echo $html-input('Owner/first_name', array('size' = '40')) ?/p ?php echo print_r($data); ? p?php echo $html-submit('Save') ?/p /form Any help would be appreciated. Thanks, Jamie --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help with associations and scaffolding
So I have a cookbook application with recipes and categories: Recipes id:title:recipe:created_on:category_id Categories id:name I am trying to use bake to setup the associations between the categories and recipes: CATEGORY MODEL class Category extends AppModel { var $name = 'Category'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasMany = array( 'Recipe' = array('className' = 'Recipe', 'foreignKey' = 'category_id', 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'dependent' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ), ); } RECIPE MODEL class Recipe extends AppModel { var $name = 'Recipe'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasOne = array( 'Category' = array('className' = 'Category', 'foreignKey' = 'id', 'conditions' = '', 'fields' = '', 'order' = '', 'dependent' = '' ), ); } Do I have the concept or am I missing something? I also had bake setup the controllers and views for me. When I view a recipe say with category_id = 2, category 1 shows up under views. Also should the add/edit view generated by scaffold have the categories as a select box with the categories in it? Right now I have a text box which makes me think that I don't have the associates set up correctly. Thanks Mark --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help in Associations
Hello Everyone, I am trying to create an application where I have currently 2 tables - a) users (id/username/password/email/name/created/modified) b) profiles (lots of blah) The association would be user hasOne profile and profile belongTo user. Now, when I am signing the user up, my signup process is spread across 2-3 pages. The fields are not such that step 1 has everything corresponding to users table and step23 have everything corresponding to profies table. I want to be able to take user input in any manner (not tied in with the order of fields in the db) but in the end once the user finishes the registration, all data needs to go to the correct place. So, I could keep track of all data in the session, finally do an array merge and then what should I do? If I call the save through any one controller will data go into both the tables properly because of associations? What approach should I be taking here? Could someone please help me out. Thank you, Mandy. --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---