Re: Having to redeclare conditions in generateList()
Thanks Grant, that makes sense. Is there any way then to define the Model such that it has it's own built-in conditions? i.e. not reliant on an association? Eg: class Designer extends AppModel { var $name = 'Designer'; var $useTable = 'employees'; var $condition = 'Employee.is_designer = 1'; } The model then only models a certain view on the database. On Aug 17, 12:10 pm, Grant Cox <[EMAIL PROTECTED]> wrote: > Because the conditions on your association are only on the association > - so only used when Cake automatically retrieves associated records. > > When you call $this->Job->Designer you are accessing a Designer model > instance - you are NOT accessing an "associated" Designer model > instance. It's just a clean new instance, so has no idea of any > conditions on other models' 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 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 -~--~~~~--~~--~--~---
Having to redeclare conditions in generateList()
Hi there. I have an association defined in a model with a condition set. Eg in my Job model: var $belongsTo = array( 'Designer' => array( 'className' => 'Employee', 'foreignKey' => 'designer_id', 'conditions' => 'Employee.is_designer = 1' ) ); However when I access the associated model with generateList, I have to again specify the condition, or else I get an entire listing of Employees. $this->Job->Designer->generateList('Employee.is_designer = 1', 'Employee.first_name ASC', null, '{n}.Employee.id', '{n}.Employee.first_name'); Why doesn't it remember how I first set up the association? --~--~-~--~~~---~--~~ 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: Multiple field values in select box?
http://php-coding-practices.com/cakephp-specific/how-to-put-combined-fields-into-cakephps-model-generatelist/ --~--~-~--~~~---~--~~ 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: BeforeFilter in Model
Have you used some debug statements to check if you're getting what you think you're getting from that loop? Chris On Aug 7, 4:48 am, Mike Digital Egg <[EMAIL PROTECTED]> wrote: > Hi Samuel, > > Thanks for your reply, I'm sure this is the right solution, I just > can't seem to get it to work: > > function afterFind( $results ) { > foreach ($results as $key => $val) { > if ( isset($val["Product"]["list_price"]) ) { > $results[$key]["Product"]["list_price"] = > $val["Product"] > ["list_price"] - 1.99; > } > } > return $results; > } > > It is just not applying the discount, is the code correct? Am I > missing something? > > Thanks > > Mike > > On Aug 6, 6:06 pm, "Samuel DeVore" <[EMAIL PROTECTED]> wrote: > > > function afterFind($results) { > > foreach ($results as $key => $val) { > >// do your thing > > } > > } > > return $results; > > } > > > On 8/6/07, Mike Digital Egg <[EMAIL PROTECTED]> wrote: > > > > Hi Tulio, > > > > Thanks for the tip, I think that might have been what I was thinking > > > of :) > > > > I have tried it in the model though and it doesn't seem to work: > > > > function afterFind( $results ) { > > > $results->list_price = $results->list_price - 1.99; > > > return $results; > > > } > > > > Am I using the correct code here? > > > > I would expect all the prices throughout the site to be - 1.99 but > > > they are still the same. > > > > Any ideas? > > > > Cheers > > > > Mike > > > > On Aug 6, 5:57 pm, Tulio Faria <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > > you could use: afterFind($results) where $results is the result of the > > > > find, like findAll... > > > > > []'s > > > > > On Aug 6, 12:52 pm, Mike Digital Egg <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > > > I would like to adjust a price coming out of the database at the model > > > > > level so that it is consistent throughout the site. > > > > > > I thought I had done something like this before: > > > > > > class Product extends AppModel { > > > > > > var $name = 'Product'; > > > > > > function beforeFilter() { > > > > > $this->list_price = $this->list_price - $discount; > > > > > return $this; > > > > > } > > > > > > } > > > > > > but I can't find any documentation about the beforeFilter function in > > > > > a model, maybe I did it before in Ruby on Rails? Can this be done in > > > > > Cake? > > > > > > Thanks > > > > > > Mike > > > -- > > (the old fart) the advice is free, the lack of crankiness will cost you > > > - its a fine line between a real question and an idiot > > >http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Intermittently no-response to ajax request
Greetings! I'm having an intermittent problem (ie very difficult to debug :-) with CakePHP seemingly not returning anything in response to a request. My app is largely ajax-driven. About 1 in 20 times, when an ajax request is made there is no response received from the server, and Firebug just displays "Loading...". This is happening both on my dev localhost box (Windows) and my live box (Linux). Part of the frustration is not knowing if this is a CakePHP problem, an Apache problem, or something else. Has anyone else encountered a problem like this and are there any pointers as to where one might start in debugging such an issue? Thanks in advance, Chris --~--~-~--~~~---~--~~ 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: CakePHP session lost when using Java Applet
Yes I've run into this problem too. Chris On Jul 16, 4:49 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hey All, > > I thought I would post this here since it caused me so much grief. > > I am using a java jar file to allow uploading of multiple files using > drag and drop (http://www.radinks.com/upload/). This is an awsome file > uploader and I highly recommend it. > > Anyway, my application ran fine (I am using session variables) until I > load the page with the applet. Once I load the page the session > completely dies. If I move to other pages in my app the session has > been started again. (CAKEPHP cookie is different and no session > varaibles exist). > > I found this post which put me in the right direction: > > http://groups.google.com/group/cake-php/browse_thread/thread/62248f55... > > Basically, the applet is trying to access its own "web space" which > falls outside of the current session with PHP. Cake thinks that a > "Session Hijack" is in place and kills the session. > > As the post above stated, I had to remove the hijack check in the / > cake/libs/session.php file. You find the function isValid() or valid() > in that file and have it return true all the time. > > This solved the problem. > > Anyone else experience this? Is there a way to *not* modify a cake > file to do this? > > Thanks! > > Phil --~--~-~--~~~---~--~~ 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: Use php in js files?
I think you can just rename the .js file to .php. Or you could just assign it to a js var before you include your js script. On May 11, 7:27 am, hydra12 <[EMAIL PROTECTED]> wrote: > I'm using jquery and ext.js to build a user interface. When a page > loads, I have a ext.js menu loading at the top with new, edit and > delete options. I want to click edit on the menu and have my page > reload in editable form via ajax. Here's my problem: the new button > works fine, but I can't get my edit button to work. How can I pass > the page's id from php to javascript? Here's what I have, and it > won't work since it's being loaded from a js file: > > $("#center1").load('/transportation/tickets/edit/id;? > > >'); > > Any ideas? --~--~-~--~~~---~--~~ 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: In-depth Model Tutorials
A friend of mine who uses RoR extensively saw some of my controllers the other day and remarked that they looked way too bloated. A tutorial on using Models to their full potential would be awesome! Chris --~--~-~--~~~---~--~~ 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: jQuery question!
Kjell, I completely agree. JQuery in particular is so powerful and easy to use that you're really limiting yourself by sticking with helpers. And yes, I am a jQuery fanboy :) Chris --~--~-~--~~~---~--~~ 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 avoid duplicating afterFind() logic?
Brilliant, thank you nate. Are there plans for a more "cake"ish way to do this in the future? :) Chris --~--~-~--~~~---~--~~ 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 avoid duplicating afterFind() logic?
Hello all, I have a question re Model::afterFind($results). If $results is from a "model" find it will be of structure $results[$i] [Model][Field], but if it is from an "association" find it will be of structure $results[$i][Model][$j][Field]. I end up having to duplicate my afterFind logic for each of these eventualities. Is there a better way? Cheers, Chris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
1.2 Pagination forgetting conditions?
Hi there, I've read all the posts I can find on this subject, but I'm sure there's something very simple I'm doing wrong. I'm aware no documentation yet exists for the pagination functionality in 1.2, so sorry if I'm jumping the gun a bit. I have an index view that displays a paginated table of results. On the view I have a filter form that lets me filter the result set. On form submission, the specified filters are parsed into a conditions array for use in $this->paginate($conditions) in the controller. The problem is that when I click on Next, Prev, or any of the sort links, all my conditions are lost. Is there any way to make the paginator remember the conditions that were used to filter the paginated results? I'm aware I can use the var $paginate to set "concrete" conditions for the paginator, but I want this functionality to be dynamic so that I can pass different conditions into $this->paginate() and have it remember the results on sorting and paginating. Any help would be most appreciated. Chris Domigan --~--~-~--~~~---~--~~ 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: A Super Release
Thanks to the team for all their hard work. One question I have is what is the easiest way to upgrade to the latest version. Can I just copy my whole app folder across? Or do I need to just copy the user files I have created? Cheers, Chris --~--~-~--~~~---~--~~ 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: Insert multiple related records
Thanks Mikee I did some more tinkering and ended up doing something like you suggested. Cheers for the tip! Chris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Insert multiple related records
Hi there, I've done a search and can't find anything that answers this question, so am hoping someone can help. Basically I have an Order model that hasMany OrderLine's in it. I have a view that lets me specify the Order and 'n' number of OrderLines all on one page (with a little help from some javascript). For eg, // My view Order info Reference Date required Products to order 1 2 3 etc... So what I want is to save the Order (no problem) and then save 'n' number of OrderLines as well. As you can see I've named my OrderLines with a [] at the end, so that I get an array of values to pass to my controller. What I'm wondering is if CakePHP will let me do something like this: // In my controller function placeOrder() { if (!empty($this->data)) { if ($this->Order->save($this->data)) { $order_id = $this->Order->getLastInsertId(); $this->data['OrderLine']['order_id'] = $order_id; $this->Order->OrderLine->save($this->data); } } } On the last line of that code I want it to loop through all my submitted OrderLine's and save them with an order_id of $order_id. Anyone know how I can do this, and what the required syntax is? Cheers, Chris --~--~-~--~~~---~--~~ 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: Helpers in default.thtml
So you have $helpers = array('Javascript') in your AppController? Chris --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---