why this find association model dont work?
gallery model and image model has blinded..but when i retrive images from galleries_controller i cant see any result..and see this error Warning (2): Invalid argument supplied for foreach() [APP\views \galleries\view.ctp, line 35] function view($id = null) { if (!$id) { $this-Session-setFlash(__('Invalid gallery', true)); $this-redirect(array('action' = 'index')); } $this-set('gallery', $this-Gallery-read(null,$id)); $this-Gallery-Image-find('all',array('conditions' = array('Image.gallery_id'= $id))); $this-set('images', $images); } in the gallreies/view ip put this loop ?php $i = 0; foreach ($images['Image'] as $image): $class = null; if ($i++ % 2 == 0) { $class = ' class=altrow'; } ? tr?php echo $class;? td?php $image['id'] ;?/td td?php echo $image['name'];?/td !--td?php echo $image['img_file'];?/td-- td?php echo $html-image('uploads' . DS . 'images' . DS . $image['img_file'], array('alt' = 'Gallery Image')); ?/td /tr ?php endforeach; ? -- 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
Problem with association model
Hi friend, i have a problem in the recovery of related objects. exemple: $this-Pessoa-find('all', array(fields = array(codigo), conditions = $a)); /* Return: array(1) { [0]= array(3) { [0]= array(1) { [codigo]= int(15) } [Areainteresse]= array(0) { } [Listamailing]= array(0) { } } If you perceive the object related to my search always returns empty. [Listamailing]= array(0) { } */ This problem occurs only when using the Firebird. Anybody know where I do a query of related objects in the core of cakephp? Or know how to solve this problem, or if you already went through similar problem, what is the best solution? --- Wladiston MaurĂcio de Paiva http://wladistonpaiva.com.br desenvolvedo...@gmail.com e...@wladistonpaiva.com.br +55 (31) 8435 - 5380 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
translate behavior and association model
Hi, I can't save my data in two locale. I explain : I use this translate behavior in my Post Model, in association with Product Model: class Post extends AppModel { var $name = 'Post'; var $actsAs = array('Translate' = array( 'body' = 'TranslationPostBody')); var $hasMany = array('Comment' = array( 'className' = 'Comment', 'foreignKey'= 'post_id' )); } class Product extends AppModel { var $name = 'Product'; var $hasOne = array( 'Post' = array('className'= 'Post', 'conditions' = '', 'order'= '', 'dependent'= true, 'foreignKey' = 'product_id') ); } In my ProductsController class, I use the following code to save my data : if (!$this-Product-Post-save($this-data)) { $this-flash('Echec de sauvegarde du post','/products'); $error = true; } It works the first time, for instance when a use 'fre' locale. Data are well stored in database, in i18N table. The next time, I use 'eng' locale and It does not save my post. Why ? I do not know how to debug this. An idea ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Refer to non-association model
On 7/22/07, Walker Hamilton [EMAIL PROTECTED] wrote: put: var $uses = array('User', 'Category'); ...at the top of your users_controller class It works now. Thanks Walker ! Regards, Feris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Refer to non-association model
On 7/22/07, Langdon Stevenson [EMAIL PROTECTED] wrote: Hi Feris To access an unrelated model you need to set: var $uses = array('ModelName'); in your controller. You can get more information on this from the manual. Hi Langdon, Thanks ! It works now, I looked at wrong section of the manual (model). Regards, Langdon Regards, Feris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Refer to non-association model
Hi All, I have two models : 1. Users 2. Categories Which have no model association at all. In user controller (user_controller.php), I like to view a list of categories (Category Model) but I failed. I try to use $this-Category-findAll method inside function of user controller, but it returns Notice: Undefined property: User::$Category in . What's wrong ? How can I refer to another model in controller that has no direct association with the model ? Regards, Feris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Refer to non-association model
put: var $uses = array('User', 'Category'); ...at the top of your users_controller class --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: association model
Have tried many different wayes, but with no success. I can't think out how to populate a join table which has more than two fields. In the index controller I 'm using the following: $this-set('langs', $this-Lang-findAll()); In the form: .. input fields for the seasons table ... $html-input('Season/Year'); . ... input fields for the seasons_langs table ?php foreach ($langs as $lang): ? Name: input type=text name=langData[?= $lang['Lang']['lang_id'] ?][SeasonLang][info] / ?php endforeach; ? So, in the controller I get an array: $this-params['form']['langData'][1][SeasonLang][Info] and $this-params['form']['langData'][2][SeasonLang][Info] (suppose we have two languages) Then I make a record for the season : $this-Season-save($countries_data) and then I build the arrays for the seasons_langs: $seasons_langs_data['SeasonLang']['season_id'] = $this-Season-getLastInsertID(); foreach ($this-params['form']['langData'] as $key = $value) { $countries_langs_data['SeasonLang']['lang_id'] = $key; $countries_langs_data['SeasonLang']['name'] = $value['SeasonLang']['info']; $this-Season-SeasonLang-save($seasons_langs_data); } Then in the seasons_langs table I have only one record. Cakephp saves the record for the first language in the first iteration and then just updates this record on the second iteration. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: association model
Dolorian wrote: Then I make a record for the season : $this-Season-save($countries_data) this is wrong. I mean: $this-Season-save($this-params['form']['Season']) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
association model
Hello ! I'm in a dilemma. I have the following tables: CREATE TABLE `langs` ( `lang_id` tinyint(3) auto_increment, `abrev` varchar(32), `name` varchar(32), PRIMARY KEY (`lang_id`) ) CREATE TABLE `seasons` ( `season_id` smallint(5) auto_increment, `year` varchar(16), `begin_date` date, `end_date` date, PRIMARY KEY (`season_id`) ) CREATE TABLE `seasons_langs` ( `season_id` smallint(5), `lang_id` tinyint(3), `info` text, PRIMARY KEY (`season_id`,`lang_id`) ) In the 'langs' table I'll ad different languages. So, when I add a record in the seasons table, I'll add N records in the 'seasons_langs' table (N depends on the number of the languages, i.e. the records in the 'langs' table. I am not sure wich model to choose for this schema in CakePHP. A possible approach is to define class Season { var $hasMany = array('SeasonLang'); } class SeasonLang { var $belongsTo = array('Season'); } The another approach is HABTM with the three tables. What do you think ? Best regards, Stoyan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: association model
I would bet on HABTM class Season extends AppModel { var $hasAndBelongsToMany = array ( 'Lang' = array('className' = 'Lang', 'joinTable' = 'seasons_langs')); } class Lang extends AppModel { var $hasAndBelongsToMany = array ( 'Season' = array('className' = 'Season', 'joinTable' = 'seasons_langs')); } et voilĂ .. That should work... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: association model
Thanks for the answer. I have two questions on it: 1. I need to add an array item in Langs for every table that use langs, right ? 2. 'seasons_langs' has a third filed 'info', which actually holds the specific language information (for the other tables there could be more such fields). How am I supposed to populate this fild, when the 'seasons_langs' is determined as joinTable ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: association model
Dolorian wrote: Thanks for the answer. I have two questions on it: 1. I need to add an array item in Langs for every table that use langs, right ? 2. 'seasons_langs' has a third filed 'info', which actually holds the specific language information (for the other tables there could be more such fields). How am I supposed to populate this fild, when the 'seasons_langs' is determined as joinTable ? Hmm, I was too quick to answer... I fear that you need to create a Model for seasons_langs, then and have hasMany and belongsTo tables. To get a hint, you could perhaps see what has been done for Acl, with Aro, Aco, and AroAco Models... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---