Re: find 'all' using containable issue
An IRC conversation gave me the solution : containable behavior had to be attached in the model and not in the controller. On Apr 29, 2009, at 08:51 , Zeugme wrote: > Hi, > > I'm not able to make containable fully work. > I have a A with many B and I want to find A with their B but only > few fields. > > Here is what I did : >$this->set('A', >$this->A->find('all', array( > 'conditions' => array ('A.id' => $id), > 'fields' => array('id', 'name'), // OK > 'contain' => array( > 'S' => array( // still OK >'fields' => array('S.id', 'S.name', 'S.a_id') // > Do not work ! > ) > // 'D' // That was for testing relation and it worked > fine. > ) >))); > > > It work partially : I'm able to get S and/or D and this is cool to > select relations. > But I'm not able to restrict field on S. > The restriction (outside the containable) on A works fine. > Any idea ? > > Models are OK. > I try to follow the exemple given in the official doc, > the last one here : http://book.cakephp.org/fr/view/474/Containable > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
find 'all' using containable issue
Hi, I'm not able to make containable fully work. I have a A with many B and I want to find A with their B but only few fields. Here is what I did : $this->set('A', $this->A->find('all', array( 'conditions' => array ('A.id' => $id), 'fields' => array('id', 'name'), // OK 'contain' => array( 'S' => array( // still OK 'fields' => array('S.id', 'S.name', 'S.a_id') // Do not work ! ) // 'D' // That was for testing relation and it worked fine. ) ))); It work partially : I'm able to get S and/or D and this is cool to select relations. But I'm not able to restrict field on S. The restriction (outside the containable) on A works fine. Any idea ? Models are OK. I try to follow the exemple given in the official doc, the last one here : http://book.cakephp.org/fr/view/474/Containable --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how data[index] is computed for HTML form ?
Hi, I wonder where I could find detailed information on how data[index] is computed on HTML form for the cases of various relation in the model. What I mean by data[index] is for example data[name] for a Person when a person creation form is submited, you can see that also on the HTTP post. Now, if a Person belongs to Something, you'll see data[something_id] ... I have now the complex case of several HATBM from Person to SomethingElse, so in the model my arrays has defferent name : var $hasAndBelongsToMany = array( 'relation1' => array( 'className' => 'T', 'joinTable' => 'Person_T_relation1', 'foreignKey' => 'person_id', 'associationForeignKey' => 't_id', ), 'relation2' => array( 'className' => 'T', 'joinTable' => 'Person_T_relation2', 'foreignKey' => 'person_id', 'associationForeignKey' => 't_id', ) ); it works fine "by hand" but it failed from HTML form. What is the index in data[index] here for relation1 and 2 ? 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 -~--~~~~--~~--~--~---
HABTM confusion was: How to add item using HABTM relation
Hi Rob and thanks, I did already what you show but the issue was on client side, I found the solution : name the HTML element with data[Person][Person][0] on a contract creation form witch is really not intuitive ! Now back the controller I have to delete a contract. I read here http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior a very interesting article but I still don't understand the difference between add and delete. Add : if I put the right ID in data[Person][Person][0] it work fine Delete look like an update, so the idea is to put in ata[Person] [Person][0], ata[Person][Person][1], ... the ID you want to keep. => this ends up with an update : fine but then, adding should remove the previously associated element, how it can work ??? On 4 Dec 2008, at 03:15, Rob wrote: > > You need to structure the data so that it has the right data and keys > for each record that will be added. > > Your $this->data['Contract']['Person'] would be an array of the data > required for the person. > > Since it appears you are doing this in your contracts controller, you > would need to get the ID for the person, then save the contract just > as you've shown. > > I do something similar in my code: I have a "signup" sheet that uses > the currently logged in user's ID to add a row to the signup slots: > >$this->User->create(); >if ( $this->User->save($this->data) ){ >$this->data['User']['user_id'] = $this->User- >> getLastInsertId(); >$this->data['UserSlot']['user_id'] = $this->data > ['User']['user_id']; > >$this->User->UserSlot->create(); > >if ($this->User->UserSlot->save($this->data > ['UserSlot'])) { >$user_slot_id = $this->User->UserSlot- >> getLastInsertId(); > > > Basically I create the user, get the user ID, set the UserSlot's > user_id, and save the UserSlot ... > > So as long as you set the data for the HATBM id's correctly, the rows > will be created. > > On Dec 3, 9:57 am, Zeugme <[EMAIL PROTECTED]> wrote: >> Hi, >> >> How to add an item to a HABTM relation ? >> >> I have a Person and I have to add a Contract to that person. >> Here are the data on a view : >> >> data[Contract][type] : 12 >> data[Contract][name] : contract-AAaa >> data[Contract][Person] : 26 // Should I put the person id here ?? or >> something else ?? >> >> In fact, that contract added to person 26 could be later on added to >> another Person, that's why its HABTM. >> Currently, I'm trying to add a new contract to an existing person, so >> the question, but later I'm not sure how to just link an existing >> contract to an existing person ... >> >> Here is the code on the controller to receive that data : >> function add() { >> if (!empty($this->data)) { >> $this-> Contract->create(); >> if ($this-> Contract->save($this->data)) { >> $this->set('returncode', 'Contract '. >> $this-> Contract->id.' >> saved'); >> } else { >> $this->set('returncode', 'ERROR : >> Contract '.$this- >> >data['Contract']['name'].' not saved'); >> } >> } >> } >> >> 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
How to add item using HABTM relation
Hi, How to add an item to a HABTM relation ? I have a Person and I have to add a Contract to that person. Here are the data on a view : data[Contract][type] : 12 data[Contract][name] : contract-AAaa data[Contract][Person] : 26 // Should I put the person id here ?? or something else ?? In fact, that contract added to person 26 could be later on added to another Person, that's why its HABTM. Currently, I'm trying to add a new contract to an existing person, so the question, but later I'm not sure how to just link an existing contract to an existing person ... Here is the code on the controller to receive that data : function add() { if (!empty($this->data)) { $this-> Contract->create(); if ($this-> Contract->save($this->data)) { $this->set('returncode', 'Contract '.$this-> Contract->id.' saved'); } else { $this->set('returncode', 'ERROR : Contract '.$this- >data['Contract']['name'].' not saved'); } } } 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
delete HATBM relation
Hi, I'd like to delete HATBM relation between a Person and a Contract. The HATBM relationship is declared in the Person model and works fine for retreiving the right person with all its contracts for example. How should I submit things to my controller method in term of data[ ? ] to just delete the relationship keeping contract ? I don't understand how to structure the data array on the client side (view). 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HTTP named parameter without URL
Hi, I'd like to pass parameter to CakePHP without URL. I set with Javascript some HTTP request named parameter and I'm not abme to retreive it on my controller. When I search in the doc, I always found the way to get parameters from URL : .../action/param1/param2 or the 1.2 way : .../action/ name1:value1/name2:value2 Any idea on how to retreive named HTTP parameter in the action without using the URL ? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Migration RC2 -> RC3 and more generally
Hi, I found myself not sure about what to change and what to keep on a CahePHP upgrade : For the cake folder, its pretty clear : remove the old one and copy the new one. What about the app folder ? Can I safely keep the old one ? That folder is full of modified files but the new version might have upgraded the file. I'm talking here about files provided by CajePHP like config/ core.php ... 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Javascript framework
Hi the list, I'm using CakePHP and I would like : * more structuration (AJAX, ...) on the presentation layer : javascript framework * widgets like table, tree and layouts like inner windows, ... : widgets library. => So i'm in the process of choosing a javascript framework / wigets libraries that works well with CakePHP. I would really appreciate your comments on the following product or your ideas on other I don't klnow yet : OpenLaszlo : I'm not sure I could integrate OpenLazslo with CakePHP, but this provide great widgets and structuration all in XML. iUi et Webapp.net : both micro framework are dedicated to iPhone, provides good AJAX encapsulation but no widgets and nothing outside iPhone. Dojo : Lack of widgets but good presentation layer structuration. Lack of documentation. JQuery : Look to me simpler than Dojo, good for presentation layer structuration but no real widgets. Scripttaculous : only good for graphical effect but not a choice for widgets or presentation layer structuration. GWT : nothing to do with Javascript side as Javascript is generated from Java. YUI : Look like a very good widget library ! Not sure about how hard it could be to integrate with CakePHP... Also I'm not sure about presentation layer structuration. Pushed by Yahoo witch is a good point. qooXdoo : like YUI, seem to be a good widget library, I don't know how to compare it to YUI... Also I'm not sure about presentation layer structuration. Any feedback appreciated ! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Leadership issues.... Changes at the top
Hi Cake list ! I'm confused. It is probably due to the long, long long IRC log, combine to the fact English is not my native language, combine to the fact I didn't took all the time I should to digg, but the result is I'm confused. Could one point out clearly the changes if any ? What are the impacts on us who use that wonderfull CakPHP as a developer or adviser or consultant or software architect for our customer ? In other words, a clear and simple summary ... :-) Thanks for developping CakePHP ! --~--~-~--~~~---~--~~ 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: bake
Thanks, I'll have a look. Why not reusing scaffold templates ? Bake could be seen as a static scaffold, isn't it ? So saving the result of a scaffold template could be the bake result. Doing so will : * merge that part * make bake as flexible as scaffold I'm not sure ... I'll read that code, try to understand and I'll see ... Thanks again. Takuo SHIONO wrote: > Hello, > > The code to deduce table relationship is in ModelTask::doAssociations() > defined in /cake/console/libs/tasks/model.php > You also have to check Inflector class defined in > /cake/libs/inflector.php. This define naming conventions. > > I think this mechanism is based on the cakePHP naming convention and > there is no template for this purpose. So you need modify the source > code in order to customize bake behaviors. > > > Best Wishes, > > Takuo Shiono > > zeugme wrote: > >> Sorry for reposting but I really would like to custimize bake >> generation, if it is possible. >> Are there templates ? Same as scaffolding ? >> >> Also, I need more info on table relationship taken into account in the >> generated model. >> >> Any clue appreciated, including pointer to the cake code >> >> zeugme wrote: >> >>> Hi the list ! >>> >>> Do you know if the bake generator is able to deduce table relationship >>> when it generate the model ? >>> If it is possible, I suppose it need a DB strict name convention ... any >>> info, doc, tuto, examples, >>> >>> Also, how to customize baked view, model, controller ? Any tips, >>> example, recommendation ? >>> Where could I find documented all the "special variable" available ? >>> (I'm guessing I'll need an array of the field in a view for example) >>> >>> Thanks ! >>> >>> >>> >> > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
bake
Sorry for reposting but I really would like to custimize bake generation, if it is possible. Are there templates ? Same as scaffolding ? Also, I need more info on table relationship taken into account in the generated model. Any clue appreciated, including pointer to the cake code zeugme wrote: > Hi the list ! > > Do you know if the bake generator is able to deduce table relationship > when it generate the model ? > If it is possible, I suppose it need a DB strict name convention ... any > info, doc, tuto, examples, > > Also, how to customize baked view, model, controller ? Any tips, > example, recommendation ? > Where could I find documented all the "special variable" available ? > (I'm guessing I'll need an array of the field in a view for example) > > Thanks ! > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
bake generator
Hi the list ! Do you know if the bake generator is able to deduce table relationship when it generate the model ? If it is possible, I suppose it need a DB strict name convention ... any info, doc, tuto, examples, Also, how to customize baked view, model, controller ? Any tips, example, recommendation ? Where could I find documented all the "special variable" available ? (I'm guessing I'll need an array of the field in a view for example) Thanks ! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Mac OS developper setup : solution
Problem solved. Here is how : Beware of the Finder. This application hide hidden file :-) So, I unziped the cake distrib via zipeg or the zip utility, no problem. Then, using the Finder, I copy/past all files in my web folder. All files ? No, not all files. That was the problem. There is a root .htaccess file that had not been part of the copy/past, thanks to the Finder. cp -R is your friend. Thanks to all ! zeugme wrote: > OK, I'm totally blocked on that issue now. Is it or not a mod_rewrite > issue ? > > Here more details : > If I try that URL in the browser > http://localhost/app/webroot/js/jquery-1.2.2.pack.js > it works fine, I got the javascript. > > http://localhost/js/jquery-1.2.2.pack.js > that one doesn't work but that is the helper's result in my layout ... I > can see it with a view source. > of course, nothing is rendered correctly ... > > => it's like webroot is not webroot ! > > I tried to update .htaccess as suggested without changing DocumentRoot, > > I also try to move the DocumentRoot (just one or two clicks with MAMP) > to my web folder. > This would make the DocumentRoot to be the folder c > ontaining /app and /cake (others) and also have a index.php is that right ? > > > MonkeyGirl wrote: > >>> I created a symlink from MAMP htdocs to my dev web folder. >>> >>> I'm not sure but I think I might have a mod_rewrite issue, maybe due to >>> that MAMP htdocs symlink or apache default config ? >>> >>> >> There's a good chance that using a symlink instead of actually >> changing httpd.conf's DocumentRoot is causing the issue. Try putting >> "RewriteBase /" in your .htaccess file just after "RewriteEngine on". >> >> Hope that helps, >> Zoe. >> >> >> > > > > > > --~--~-~--~~~---~--~~ 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: Mac OS developper setup
OK, I'm totally blocked on that issue now. Is it or not a mod_rewrite issue ? Here more details : If I try that URL in the browser http://localhost/app/webroot/js/jquery-1.2.2.pack.js it works fine, I got the javascript. http://localhost/js/jquery-1.2.2.pack.js that one doesn't work but that is the helper's result in my layout ... I can see it with a view source. of course, nothing is rendered correctly ... => it's like webroot is not webroot ! I tried to update .htaccess as suggested without changing DocumentRoot, I also try to move the DocumentRoot (just one or two clicks with MAMP) to my web folder. This would make the DocumentRoot to be the folder c ontaining /app and /cake (others) and also have a index.php is that right ? MonkeyGirl wrote: >> I created a symlink from MAMP htdocs to my dev web folder. >> >> I'm not sure but I think I might have a mod_rewrite issue, maybe due to >> that MAMP htdocs symlink or apache default config ? >> > > There's a good chance that using a symlink instead of actually > changing httpd.conf's DocumentRoot is causing the issue. Try putting > "RewriteBase /" in your .htaccess file just after "RewriteEngine on". > > Hope that helps, > Zoe. > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Mac OS developper setup
Hi, I'm wondering what kind of software setup are you using on Mac OS as a developper machine ? I'm using MAMP for the Apache, PHP, MySQL stack and IntelliJ for code edition. I created a symlink from MAMP htdocs to my dev web folder. I'm not sure but I think I might have a mod_rewrite issue, maybe due to that MAMP htdocs symlink or apache default config ? --~--~-~--~~~---~--~~ 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: How to do just a view ?
Ola Juan ! Thanks a lot : you gave me the keywords I didn't had that prevent me for searching more ! ($uses and _javascript_ helper) Thanks again. Juan F. Gimenez Silva wrote: El lun, 04-02-2008 a las 02:21 -0800, zeugme escribió: Hi, Hello (also, hello to all bakers!), I'm new in CakePHP, amazingly, I choose CakePHP for the power of MVC, SQL mapping ... It's nice to hear that, I'm pretty much a newbie too. but I need to deal with my home page witch have no model. This page however is not purely static, it contains PHP, SQL ... Where do I put such files ? /app/webroot ? or /app/view.pages ? I think the easiest way to do that would be to create a controller with a home() action that uses (see the $uses variables) the models where you need to get the data for the home page. That way you can create methods on the models involved to return the data, so, no need for SQL at all. What are the differences between those 2 folders ? This page also rely on some _javascript_ framework (JQuery). Where do I put my jquery.js file ? If I put it inside app/webroot/js it doesn't appears to be taken into account ... It's like if I had to put that general js files at the physical root, the folder that contains /app. No, you have to put it in app/webroot/js, and load it using the _javascript_ Helper, remember to load the helper on the appropiate controller. Maybe there is some doc I should read ? I read the manual, tuto, browse the bakery and did not found, but that do not mean it doesn't exists :-) Thanks for your help ! I hope that helps! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to do just a view ?
Hi, I'm new in CakePHP, amazingly, I choose CakePHP for the power of MVC, SQL mapping ... but I need to deal with my home page witch have no model. This page however is not purely static, it contains PHP, SQL ... Where do I put such files ? /app/webroot ? or /app/view.pages ? What are the differences between those 2 folders ? This page also rely on some javascript framework (JQuery). Where do I put my jquery.js file ? If I put it inside app/webroot/js it doesn't appears to be taken into account ... It's like if I had to put that general js files at the physical root, the folder that contains /app. Maybe there is some doc I should read ? I read the manual, tuto, browse the bakery and did not found, but that do not mean it doesn't exists :-) Thanks for your help ! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---