Re: cakephp manual question
There is no difference. You can use both, but in the latter case You have to add Comment to the uses array of the controller, so $this-Post-Comment-save() is better way On Jan 24, 11:38 am, bob [EMAIL PROTECTED] wrote: This is a newbie question. In the cakephp manual (http://manual.cakephp.org/chapter/models) $this-data['Comment']['post_id'] = $post_id; //Because our Post hasMany Comments, we can access //the Comment model through the Post model: $this-Post-Comment-save($this-data); Why do we need to do $this-Post-Comment-save($this-data) instead of simply $this-Comment-save($this-data)? what difference does it make in this case, since we know the specific post_id? --~--~-~--~~~---~--~~ 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: array reformat
Maybe postConditions(...) is what You are looking for. It's a controller's method, and You can use it like this: $data = $this-postConditios($this-data) On Dec 20, 4:55 pm, mithnik [EMAIL PROTECTED] wrote: In case someone needs this here is the solution: no cake used: /* * Usage $data (array to be transformed), $result = null- to hold the result * transform($data, $result); */ function transform($input, $output, $key_path = array()) { foreach ($input as $key = $value) { if(is_array($value)) { $key_path[] = $key; transform($input[$key], $output, $key_path); array_pop($key_path); } else { $path = implode(., $key_path); $output[$path...$key] = $value; } } } --~--~-~--~~~---~--~~ 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: set a date on default.ctp, on all pages?
or, if You need to place in all views something more sophisticated, You can add $this-set(...) to beforeFilter in app_controller On Dec 10, 7:03 am, Louie Miranda [EMAIL PROTECTED] wrote: I have added this on one of my controller for function index() $this-set('date', date(r)); And added ?php echo $date; ? On /app/views/layout/default.ctp It works only on that controller, and when i go to other pages. Obviously, i would add $this-set('date', date(r)); this for all to be able to work. Is there like a global preference for this kind of things? It would be tiring to set this for all of my controllers and functions. Thanks -- Louie Miranda ([EMAIL PROTECTED])http://www.axishift.com Security Is A Series Of Well-Defined Steps chmod -R 0 / ; and smile :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---