Re: CakePHP Newbie Questions
No doubt you've seen http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html With this, you set up the Auth component to tell it how you're doing your Auth, and what the loginAction should be. Once a user request comes in for a page that requires authentication, and if they're not Authentication, the component will redirect the user to the login action, get them logged in, and then redirect them to the original page they were trying to get to. Of course, you're free to directly display your login action as well. As mentioned before, Controllers don't need a Model, but will use convention to determine a model to use, if one is not supplied. If you want a controller with no Models, use public $uses = false or public $uses = array(), as described here : http://book.cakephp.org/2.0/en/controllers.html#Controller::$uses When you set up the Auth component, you'll also set up a model that is used for that authentication. Usually it's a User model, with a username and password. To access any fields in the auth model for the current authentication session, from the controller, use $this->Auth->user(); i.e. $this->Auth->user('username') will give you the user name of the currently logged in user. As seen here: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user I hope that answers your questions. Regards Reuben Helms On Wednesday, 18 December 2013 03:21:50 UTC+10, Nick Harper wrote: > > Hi, > > I have recently started to learn CakePHP after just being used to coding > from scratch. > > I have installed a couple of plugins but the issue I have is linking them > together, for example if I have a login script then how on earth do I just > show the login page for example? > > Does every Controller need to have a mysql assigned to it? > > I have been through the blog tutorial but so far it just feels really > restrictive compared to just coding from scratch but what really appeals is > the plugins / helpers but I am just struggling with basic things like > echoing the username they are logged in with when logged in etc. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: CakePHP Newbie Questions
Hey Nick, I know your pain .. I suggest watching these videos http://www.youtube.com/playlist?list=PL20D663BEC6319E36 they will really help explain and walk you through setting up a login / logout Hopefully that helps you and get you moving on your application. Cheers On Tuesday, December 17, 2013 12:21:50 PM UTC-5, Nick Harper wrote: > > Hi, > > I have recently started to learn CakePHP after just being used to coding > from scratch. > > I have installed a couple of plugins but the issue I have is linking them > together, for example if I have a login script then how on earth do I just > show the login page for example? > > Does every Controller need to have a mysql assigned to it? > > I have been through the blog tutorial but so far it just feels really > restrictive compared to just coding from scratch but what really appeals is > the plugins / helpers but I am just struggling with basic things like > echoing the username they are logged in with when logged in etc. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: CakePHP Newbie Questions
Hi Nick, Well every thing has a learning curve so be patient and you'll get the gist of it. I've used almost all PHP frameworks and by far Cake is the one that is easiest to learn and use. To answer your question: No, you don't need a "mysql" assigned to the controller. By "mysql" I guess you mean Model. Cake will try to load a view with the same name of the method in the controller. So if your Controller named "ProductsController" is called and within it the method "index", then Cake will load a view with name "index.ctp" from app/Views/Products. In the view you can put whatever you want. Because cake is trying to give you a solid ground for a quick start if you have a model named "Product" then Cake will try to load it also. And if you don't have a DB table assigned to that model then Cake will be unhappy. If you don't want that just use property $uses and set it to array(). On Tuesday, December 17, 2013 7:21:50 PM UTC+2, Nick Harper wrote: > > Hi, > > I have recently started to learn CakePHP after just being used to coding > from scratch. > > I have installed a couple of plugins but the issue I have is linking them > together, for example if I have a login script then how on earth do I just > show the login page for example? > > Does every Controller need to have a mysql assigned to it? > > I have been through the blog tutorial but so far it just feels really > restrictive compared to just coding from scratch but what really appeals is > the plugins / helpers but I am just struggling with basic things like > echoing the username they are logged in with when logged in etc. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
CakePHP Newbie Questions
Hi, I have recently started to learn CakePHP after just being used to coding from scratch. I have installed a couple of plugins but the issue I have is linking them together, for example if I have a login script then how on earth do I just show the login page for example? Does every Controller need to have a mysql assigned to it? I have been through the blog tutorial but so far it just feels really restrictive compared to just coding from scratch but what really appeals is the plugins / helpers but I am just struggling with basic things like echoing the username they are logged in with when logged in etc. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Media Plugin - Newbie Questions
I don't know anything about the Media plugin, however your problem may be with how you have created your inputs in the view. Have you looked at the structure of $this->data once the form has been submitted to your action (admin_add)? In order for saveAll() to work. It should look something like: array( [PressRelease]=>array( [date]=>// some date . // other fields . [Attachment]=>array( [file]=>// some file name In your view you have: echo $this->Form->input('file', array('label' => 'File', 'type' =>'file')); It may be as simple as changing this to: echo $this->Form->input('Attachment.file', array('label' => 'File', 'type' =>'file')); BTW, saveAll() will save related model data ONLY if the array passed is properly structured AND it is only one level deep. HTH, Ken -- 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
Media Plugin - Newbie Questions
I'm trying to set up the Media plugin, but am having problems. I have a PressRelease model, and while adding an entry I would like to choose and upload a PDF file to associate with it. But when adding an entry, the press_releases table receives an entry, and the attachment table does not. *If I use the baked Attachment view to add an entry the attachments table DOES receive the row. I have followed the documentation, updated the bootstrap file, etc. Below is the relevant code from the Press Release model, controller and view. If you have any idea what I correct, please advise. Thanks! A few simple questions also: 1. Do I need to add this ... var $helpers = array('Media.Media'); ... to my PressRelease model? 2. Do I need to add "belongsTo" data to the Attachment model? -- Code Provided Below -- The Press Release model has this: var $hasOne = array( 'Attachment' => array( 'className' => 'Media.Attachment', 'foreignKey' => 'foreign_key', 'conditions' => array('Attachment.model' => 'PressRelease'), 'dependent' => true, )); The Press Release controller has this: function admin_add() { $this->layout = 'admin'; if (!empty($this->data)) { $this->PressRelease->create(); if ($this->PressRelease->saveAll($this->data, array('validate' => 'first'))) { $this->Session->setFlash('The press release has been saved.', 'flash_success'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash('The press release could not be saved. Please, try again.', 'flash_error'); } } $projects = $this->PressRelease->Project->find('list'); $this->set(compact('projects')); } The form in the view looks like this: Form->create('PressRelease', array('enctype' => 'multipart/form-data'));?> Form->input('date', array('type'=>'date', 'minYear'=>2005, 'maxYear'=>$max_year, 'selected'=>$unix_timestamp)); echo $this->Form->input('title'); echo $this->Form->input('file', array('label' => 'File', 'type' => 'file')); echo $this->Form->input('Project',array('label'=>'Related Project(s)', 'multiple' => 'checkbox')); ?> Form->end(__('Add Press Release', true));?> -- 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: Newbie questions regarding views files and layout
On Sun, Jun 27, 2010 at 3:08 PM, jimbo wrote: > I have been looking through the documentation and tutorials regarding > changing the default layout. When the home page is loaded it states > "To change its layout, edit: C:\CakePHP\uniform\UniServer\www > \project1\views\layouts\default.ctp" however, the other articles that > I have read state that creating a default.thml file will override the > default style. When I try to create a default.thml in \views\layouts\ > the page does not render the new layout. When I alter the default.ctp > file it does. It seems (at least from what I have read) that both .ctp > and .thml are views files. Can someone explain the difference between > them and maybe suggest what I might be doing wrong? Thank you in > advance. .thml is an old extension. Cake uses .ctp now. Always look for a date on any articles about Cake that you find online. There have been a lot of changes. Articles that reference the .html extension are probably way out of date. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Newbie questions regarding views files and layout
I have been looking through the documentation and tutorials regarding changing the default layout. When the home page is loaded it states "To change its layout, edit: C:\CakePHP\uniform\UniServer\www \project1\views\layouts\default.ctp" however, the other articles that I have read state that creating a default.thml file will override the default style. When I try to create a default.thml in \views\layouts\ the page does not render the new layout. When I alter the default.ctp file it does. It seems (at least from what I have read) that both .ctp and .thml are views files. Can someone explain the difference between them and maybe suggest what I might be doing wrong? Thank you in advance. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: some newbie questions
that's exactly what i wanted to know, thank you. On Sep 19, 6:35 pm, Hols Kay wrote: > Yes - because it's coming from the URL it's not *strictly* necessary > to redefine it in your controller, but defining it in the controller > is generally better coding style because the explicit relationship is > easier to see at-a-glance. It also means that you're better able to do > checks on the id number, for example: > > function index($id = null){ > if (!$id) { > $this->set('model', $this->Model->read(null, '1')); > } else { > if(!is_numeric($id)) { > $this->set('model', $this->Model->read(null, > '1')); > } else { > $this->set('model', $this->Model->read(null, > $id)); > } > } > } > > It's really just a style of coding that increases clarity (or not, as > the case may be ;) ). > > On Sep 19, 4:49 pm, lorenx wrote: > > > > > > 1. Cake's reading the id from the url. You're saying, in the url, > > > 'show me the Post controller / the View method / and record number > > > #n', and Cake's handling that for you automatically. > > > sure but... what if i comment out all the $id reference? > > this cleaned code: > > function view() { > > $this->set('post', $this->Post->read());} > > > continues to work properly; it seems that the $this->Post->id=$id > > assignment is not necessary... > > > > 2. Post/Somefunction only becomes a valid URL if you make a > > > corresponding view file for it. You can, if you want, use private > > > methods by marking a method with a preceding underscore, so: > > > > _method() { //code } > > > > That'll make the method only accessible to other methods within the > > > controller. You can also use routes to redirect users around if they > > > try to access a method through the url that they shouldn't be using. > > > perfect. > > > 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: some newbie questions
Yes - because it's coming from the URL it's not *strictly* necessary to redefine it in your controller, but defining it in the controller is generally better coding style because the explicit relationship is easier to see at-a-glance. It also means that you're better able to do checks on the id number, for example: function index($id = null){ if (!$id) { $this->set('model', $this->Model->read(null, '1')); } else { if(!is_numeric($id)) { $this->set('model', $this->Model->read(null, '1')); } else { $this->set('model', $this->Model->read(null, $id)); } } } It's really just a style of coding that increases clarity (or not, as the case may be ;) ). On Sep 19, 4:49 pm, lorenx wrote: > > 1. Cake's reading the id from the url. You're saying, in the url, > > 'show me the Post controller / the View method / and record number > > #n', and Cake's handling that for you automatically. > > sure but... what if i comment out all the $id reference? > this cleaned code: > function view() { > $this->set('post', $this->Post->read());} > > continues to work properly; it seems that the $this->Post->id=$id > assignment is not necessary... > > > 2. Post/Somefunction only becomes a valid URL if you make a > > corresponding view file for it. You can, if you want, use private > > methods by marking a method with a preceding underscore, so: > > > _method() { //code } > > > That'll make the method only accessible to other methods within the > > controller. You can also use routes to redirect users around if they > > try to access a method through the url that they shouldn't be using. > > perfect. > > 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: some newbie questions
> 1. Cake's reading the id from the url. You're saying, in the url, > 'show me the Post controller / the View method / and record number > #n', and Cake's handling that for you automatically. sure but... what if i comment out all the $id reference? this cleaned code: function view() { $this->set('post', $this->Post->read()); } continues to work properly; it seems that the $this->Post->id=$id assignment is not necessary... > 2. Post/Somefunction only becomes a valid URL if you make a > corresponding view file for it. You can, if you want, use private > methods by marking a method with a preceding underscore, so: > > _method() { //code } > > That'll make the method only accessible to other methods within the > controller. You can also use routes to redirect users around if they > try to access a method through the url that they shouldn't be using. perfect. 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: some newbie questions
1. Cake's reading the id from the url. You're saying, in the url, 'show me the Post controller / the View method / and record number #n', and Cake's handling that for you automatically. 2. Post/Somefunction only becomes a valid URL if you make a corresponding view file for it. You can, if you want, use private methods by marking a method with a preceding underscore, so: _method() { //code } That'll make the method only accessible to other methods within the controller. You can also use routes to redirect users around if they try to access a method through the url that they shouldn't be using. 3. Be careful with that - the $form->something syntax is used only by the form helper. Cake will automatically build your form inputs so long as you name them properly, so if you've got $form->input ('Model.fieldname'); then Cake will work its magic on that field and model. In your edit example, $this->data is the array that's retrieved from the form - in the edit.ctp file itself, the form should work like $form->input('Model.fieldname'); If you want to just display your data without the form helper, then you can use the set method in the controller: $this->set(array('mytitle'=>$this->data['Post']['title'])); This makes a variable called $mytitle available to the view template with the contents of $this->data['Post']['title'] in it. On Sep 19, 3:27 pm, lorenx wrote: > thanks to all! > ...but i still have some doubts. > > 1. > if i write: > function view() { > $this->set('post', $this->Post->read());} > > then the urls post/view/1 and post/view/2 continue to show > respectively post n.1 and post n.2, i cannot understand how (maybe i > have to look depper in the code) > > 2. > ok but... if i have two identical pieces of code and i extract them in > someFunction() then post/someFunction becomes a valid url? > if so, how to avoid this behaviour? > > 3. > ok. so $this->data in the controller becomes $form->data in the > respective ctp file. > > thanks again to all! > > On Sep 18, 9:13 pm, Hols Kay wrote: > > > 1. $this->Post->id = $id sets the model id field to whatever the id is > > that you've passed in the URL. That's retained for the $this->Post->read(); > > underneath it. You can also say things like $this->set > > > ('post', $this->Post->read(null, $id)); to read all the fields for > > record $id, for example, instead of assigning the id and then reading > > it. > > > 2. Every function in the controller IS a method, and every method IS > > an action ;) They're all synonyms for the same thing. You don't need a > > view for every controller method, only the ones that you'll logically > > want a view for, which is what I think you're meaning to ask. > > > 3. $this->data is handled automagically by Cake. It consists of an > > array of the data that you're moving from one place to another, so you > > can act on specific fields by calling $this->data['Model']['field']. > > > Hope this helps! > > > On Sep 17, 7:05 pm, lorenx wrote: > > > > hi all, > > > i'm new to cakephp and, mentioning the blog tutorial, i have some > > > simple questions. > > > > 1. > > > in the sample controller, there is the view action: > > > > function view($id = null) { > > > $this->Post->id = $id; > > > $this->set('post', $this->Post->read()); > > > > } > > > > to better understand, i did some tests. > > > i tried to comment out the passed parameter $id and the > > > $this->Post->id=$id assignment... and the code seems to work as before. > > > > i also printed_r the Post object, before and after that line, but no > > > change appeared. > > > so... what exactly do the assignment? and passing the $_GET parameter > > > is necessary? > > > > 2. > > > does every function in the controller involve the creation of a > > > method, of an action? > > > > 3. > > > in the edit action, there is the $this->data variable. > > > i presume that this variable is going to populate the edit form. how > > > is this handled? > > > > thanks to all! > > --~--~-~--~~~---~--~~ 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: some newbie questions
thanks to all! ...but i still have some doubts. 1. if i write: function view() { $this->set('post', $this->Post->read()); } then the urls post/view/1 and post/view/2 continue to show respectively post n.1 and post n.2, i cannot understand how (maybe i have to look depper in the code) 2. ok but... if i have two identical pieces of code and i extract them in someFunction() then post/someFunction becomes a valid url? if so, how to avoid this behaviour? 3. ok. so $this->data in the controller becomes $form->data in the respective ctp file. thanks again to all! On Sep 18, 9:13 pm, Hols Kay wrote: > 1. $this->Post->id = $id sets the model id field to whatever the id is > that you've passed in the URL. That's retained for the $this->Post->read(); > underneath it. You can also say things like $this->set > > ('post', $this->Post->read(null, $id)); to read all the fields for > record $id, for example, instead of assigning the id and then reading > it. > > 2. Every function in the controller IS a method, and every method IS > an action ;) They're all synonyms for the same thing. You don't need a > view for every controller method, only the ones that you'll logically > want a view for, which is what I think you're meaning to ask. > > 3. $this->data is handled automagically by Cake. It consists of an > array of the data that you're moving from one place to another, so you > can act on specific fields by calling $this->data['Model']['field']. > > Hope this helps! > > On Sep 17, 7:05 pm, lorenx wrote: > > > > > hi all, > > i'm new to cakephp and, mentioning the blog tutorial, i have some > > simple questions. > > > 1. > > in the sample controller, there is the view action: > > > function view($id = null) { > > $this->Post->id = $id; > > $this->set('post', $this->Post->read()); > > > } > > > to better understand, i did some tests. > > i tried to comment out the passed parameter $id and the $this->Post->id=$id > > assignment... and the code seems to work as before. > > > i also printed_r the Post object, before and after that line, but no > > change appeared. > > so... what exactly do the assignment? and passing the $_GET parameter > > is necessary? > > > 2. > > does every function in the controller involve the creation of a > > method, of an action? > > > 3. > > in the edit action, there is the $this->data variable. > > i presume that this variable is going to populate the edit form. how > > is this handled? > > > thanks to all! --~--~-~--~~~---~--~~ 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: some newbie questions
1. $this->Post->id = $id sets the model id field to whatever the id is that you've passed in the URL. That's retained for the $this->Post- >read(); underneath it. You can also say things like $this->set ('post', $this->Post->read(null, $id)); to read all the fields for record $id, for example, instead of assigning the id and then reading it. 2. Every function in the controller IS a method, and every method IS an action ;) They're all synonyms for the same thing. You don't need a view for every controller method, only the ones that you'll logically want a view for, which is what I think you're meaning to ask. 3. $this->data is handled automagically by Cake. It consists of an array of the data that you're moving from one place to another, so you can act on specific fields by calling $this->data['Model']['field']. Hope this helps! On Sep 17, 7:05 pm, lorenx wrote: > hi all, > i'm new to cakephp and, mentioning the blog tutorial, i have some > simple questions. > > 1. > in the sample controller, there is the view action: > > function view($id = null) { > $this->Post->id = $id; > $this->set('post', $this->Post->read()); > > } > > to better understand, i did some tests. > i tried to comment out the passed parameter $id and the $this->Post->id=$id > assignment... and the code seems to work as before. > > i also printed_r the Post object, before and after that line, but no > change appeared. > so... what exactly do the assignment? and passing the $_GET parameter > is necessary? > > 2. > does every function in the controller involve the creation of a > method, of an action? > > 3. > in the edit action, there is the $this->data variable. > i presume that this variable is going to populate the edit form. how > is this handled? > > thanks to all! --~--~-~--~~~---~--~~ 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: some newbie questions
1 - The "$this->Post->id = " tells what ID to use for read(). If no ID is passed then it wont find the correct data or it will return the first row in the database. 2 - Every page (or action, e.g., /users/login, login is the page) must be created within the respective controller. 3 - $this->data is the $_POST, or the data you passed to it. If you used the form helper, the fields should auto-populate if $this->data has values. On Sep 18, 11:45 am, Simon wrote: > nobody helps no body here sometimes you get luck we need a group > called cakephp_for_noobs > > On Sep 18, 11:40 am, lorenx wrote: > > > a little help please? > > > On Sep 17, 8:05 pm, lorenx wrote: > > > > hi all, > > > i'm new to cakephp and, mentioning the blog tutorial, i have some > > > simple questions. > > > > 1. > > > in the sample controller, there is the view action: > > > > function view($id = null) { > > > $this->Post->id = $id; > > > $this->set('post', $this->Post->read()); > > > > } > > > > to better understand, i did some tests. > > > i tried to comment out the passed parameter $id and the > > > $this->Post->id=$id assignment... and the code seems to work as before. > > > > i also printed_r the Post object, before and after that line, but no > > > change appeared. > > > so... what exactly do the assignment? and passing the $_GET parameter > > > is necessary? > > > > 2. > > > does every function in the controller involve the creation of a > > > method, of an action? > > > > 3. > > > in the edit action, there is the $this->data variable. > > > i presume that this variable is going to populate the edit form. how > > > is this handled? > > > > thanks to all!- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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: some newbie questions
a little help please? On Sep 17, 8:05 pm, lorenx wrote: > hi all, > i'm new to cakephp and, mentioning the blog tutorial, i have some > simple questions. > > 1. > in the sample controller, there is the view action: > > function view($id = null) { > $this->Post->id = $id; > $this->set('post', $this->Post->read()); > > } > > to better understand, i did some tests. > i tried to comment out the passed parameter $id and the $this->Post->id=$id > assignment... and the code seems to work as before. > > i also printed_r the Post object, before and after that line, but no > change appeared. > so... what exactly do the assignment? and passing the $_GET parameter > is necessary? > > 2. > does every function in the controller involve the creation of a > method, of an action? > > 3. > in the edit action, there is the $this->data variable. > i presume that this variable is going to populate the edit form. how > is this handled? > > thanks to all! --~--~-~--~~~---~--~~ 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: some newbie questions
nobody helps no body here sometimes you get luck we need a group called cakephp_for_noobs On Sep 18, 11:40 am, lorenx wrote: > a little help please? > > On Sep 17, 8:05 pm, lorenx wrote: > > > > > hi all, > > i'm new to cakephp and, mentioning the blog tutorial, i have some > > simple questions. > > > 1. > > in the sample controller, there is the view action: > > > function view($id = null) { > > $this->Post->id = $id; > > $this->set('post', $this->Post->read()); > > > } > > > to better understand, i did some tests. > > i tried to comment out the passed parameter $id and the $this->Post->id=$id > > assignment... and the code seems to work as before. > > > i also printed_r the Post object, before and after that line, but no > > change appeared. > > so... what exactly do the assignment? and passing the $_GET parameter > > is necessary? > > > 2. > > does every function in the controller involve the creation of a > > method, of an action? > > > 3. > > in the edit action, there is the $this->data variable. > > i presume that this variable is going to populate the edit form. how > > is this handled? > > > thanks to all!- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
some newbie questions
hi all, i'm new to cakephp and, mentioning the blog tutorial, i have some simple questions. 1. in the sample controller, there is the view action: function view($id = null) { $this->Post->id = $id; $this->set('post', $this->Post->read()); } to better understand, i did some tests. i tried to comment out the passed parameter $id and the $this->Post- >id=$id assignment... and the code seems to work as before. i also printed_r the Post object, before and after that line, but no change appeared. so... what exactly do the assignment? and passing the $_GET parameter is necessary? 2. does every function in the controller involve the creation of a method, of an action? 3. in the edit action, there is the $this->data variable. i presume that this variable is going to populate the edit form. how is this handled? thanks to all! --~--~-~--~~~---~--~~ 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: A newbie questions about URLs
Your keyword for google is "Trailing Slash Problem" http://httpd.apache.org/docs/2.0/misc/rewriteguide.html http://httpd.apache.org/docs/2.0/mod/mod_dir.html On Apr 15, 6:26 am, Beedge wrote: > I have uploaded cake to a testing folder on my domain hbit.ie to play > around with it and see what I can do. I have called my testing > folder.. wait for it 'cake' :) > > Can someone tell me if this is right.. the url > > http://hbit.ie/cake/ > > shows the installation is ok. but if i leave out the trailing slash > (http://hbit.ie/cake), I get a bad request page returned, > > Do I need to configure something, or is this normal behaviour? > > Thanks > > Kevin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A newbie questions about URLs
I have uploaded cake to a testing folder on my domain hbit.ie to play around with it and see what I can do. I have called my testing folder.. wait for it 'cake' :) Can someone tell me if this is right.. the url http://hbit.ie/cake/ shows the installation is ok. but if i leave out the trailing slash ( http://hbit.ie/cake ), I get a bad request page returned, Do I need to configure something, or is this normal behaviour? Thanks Kevin --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
Meanwhile, I have thoroughly re-read the manual on the associations, spent some time recreating db structure, rewritten the associations and now it works. Not to mention some small typos in the params (all that camel-case and stuff) Thanks anyway! (case closed) teknoid-3 wrote: > > > Where is the model association between Design and Status and vice > versa? > Your models need to know how they relate to each other. > Please review the manual as it quite clearly describes all of the > that. > > > > On Oct 18, 12:06 pm, Marritza <[EMAIL PROTECTED]> wrote: >> Ok, let me clarify finally. (Never used newsgroups before so pardon lack >> of >> complete information :P ) >> >> class Design extends AppModel { >> >> var $primaryKey = 'designs_id'; >> var $useTable = 'design'; >> >> } >> >> class Status extends AppModel { >> >> var $primaryKey = 'status_id'; >> var $useTable = 'status'; >> >> } >> >> I'm not using foreign keys. The db schema has been posted in the first >> message. >> >> >> >> teknoid-3 wrote: >> >> > If you cannot alter db structure, that's fine. Cake works perfectly >> > well with legacy DB's, but you have to ensure that you specify any >> > settings that do not follow conventions. That includes table names, >> > primary keys as well as foreign keys. >> >> > You didn't provide your model definitions, so it's hard to guess as to >> > what could be culprit. >> >> > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: >> >> Forgot to mention - I am using $prmaryKey syntax in each model, >> because I >> >> have limited possibilities to alter the db structure. Tho, it is >> possible >> >> for me to create a sample table using cake conventions, I'll try again >> >> then. >> >> >> teknoid-3 wrote: >> >> >> > You shouldn't break conventions when naming your primary keys. >> >> > Cake will expect your primary key to be named 'id'... So Design.id >> and >> >> > Status.id. >> >> >> > Of course you can override those by setting a $prmaryKey = >> 'myOwnKey'; >> >> > in the model, but why make your life more difficult? >> >> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: >> >> >> Hello! >> >> >> >> I'm using Cake for several days now, I'm still under big impression >> of >> >> >> its >> >> >> capabilities. >> >> >> >> Nevertheless, I have faced a problem, to which solution, which I >> have >> >> >> found, >> >> >> feels not logical in the Cake ways of doing things. First, let me >> show >> >> >> you >> >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). >> >> >> >> table DESIGNS >> >> >> designs_id serial <- primary key >> >> >> job_name >> >> >> status_id >> >> >> ...etc >> >> >> >> table STATUS >> >> >> status_id serial <- primary key >> >> >> name >> >> >> >> The expected outcome is simple - I'm querying the Design model to >> >> >> retrieve >> >> >> data about a job, and I expect to see the status name which is >> related >> >> >> thru >> >> >> Design.status_id => Status.status_id. >> >> >> >> Now, when I tried to accomplish it with $hasOne in the Design model >> >> the >> >> >> result is that Status is joined not on the forementioned basis, but >> on >> >> >> Design.design_id -> Status.status_id. >> >> >> >> to my surprise, it works using $belongsTo relation. >> >> >> >> Perhaps there is something wrong with my understanding of the Cake >> >> >> relation >> >> >> ways, perhaps I'm simply overlooking some basic stuff. >> >> >> >> Anyhow, any help greatly appreciated. >> >> >> >> -- >> >> >> View this message in >> >> >> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> >> >> Sent from the CakePHP mailing list archive at Nabble.com. >> >> >> -- >> >> View this message in >> >> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> >> Sent from the CakePHP mailing list archive at Nabble.com. >> >> -- >> View this message in >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> Sent from the CakePHP mailing list archive at Nabble.com. > > > > -- View this message in context: http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20059649.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
Where is the model association between Design and Status and vice versa? Your models need to know how they relate to each other. Please review the manual as it quite clearly describes all of the that. On Oct 18, 12:06 pm, Marritza <[EMAIL PROTECTED]> wrote: > Ok, let me clarify finally. (Never used newsgroups before so pardon lack of > complete information :P ) > > class Design extends AppModel { > > var $primaryKey = 'designs_id'; > var $useTable = 'design'; > > } > > class Status extends AppModel { > > var $primaryKey = 'status_id'; > var $useTable = 'status'; > > } > > I'm not using foreign keys. The db schema has been posted in the first > message. > > > > teknoid-3 wrote: > > > If you cannot alter db structure, that's fine. Cake works perfectly > > well with legacy DB's, but you have to ensure that you specify any > > settings that do not follow conventions. That includes table names, > > primary keys as well as foreign keys. > > > You didn't provide your model definitions, so it's hard to guess as to > > what could be culprit. > > > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: > >> Forgot to mention - I am using $prmaryKey syntax in each model, because I > >> have limited possibilities to alter the db structure. Tho, it is possible > >> for me to create a sample table using cake conventions, I'll try again > >> then. > > >> teknoid-3 wrote: > > >> > You shouldn't break conventions when naming your primary keys. > >> > Cake will expect your primary key to be named 'id'... So Design.id and > >> > Status.id. > > >> > Of course you can override those by setting a $prmaryKey = 'myOwnKey'; > >> > in the model, but why make your life more difficult? > > >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: > >> >> Hello! > > >> >> I'm using Cake for several days now, I'm still under big impression of > >> >> its > >> >> capabilities. > > >> >> Nevertheless, I have faced a problem, to which solution, which I have > >> >> found, > >> >> feels not logical in the Cake ways of doing things. First, let me show > >> >> you > >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). > > >> >> table DESIGNS > >> >> designs_id serial <- primary key > >> >> job_name > >> >> status_id > >> >> ...etc > > >> >> table STATUS > >> >> status_id serial <- primary key > >> >> name > > >> >> The expected outcome is simple - I'm querying the Design model to > >> >> retrieve > >> >> data about a job, and I expect to see the status name which is related > >> >> thru > >> >> Design.status_id => Status.status_id. > > >> >> Now, when I tried to accomplish it with $hasOne in the Design model > >> the > >> >> result is that Status is joined not on the forementioned basis, but on > >> >> Design.design_id -> Status.status_id. > > >> >> to my surprise, it works using $belongsTo relation. > > >> >> Perhaps there is something wrong with my understanding of the Cake > >> >> relation > >> >> ways, perhaps I'm simply overlooking some basic stuff. > > >> >> Anyhow, any help greatly appreciated. > > >> >> -- > >> >> View this message in > > >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > >> >> Sent from the CakePHP mailing list archive at Nabble.com. > > >> -- > >> View this message in > >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > >> Sent from the CakePHP mailing list archive at Nabble.com. > > -- > View this message in > context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
You are wrong, you can name your id whatever you want as long as you define it using $primaryKey Sent from my iPhone On 18-10-2008, at 16:43, "Lamonte(Scheols/Demonic)" <[EMAIL PROTECTED]> wrote: > Yeah cake its strict on everything so you can't name your id > "design_id" stupid? Yes I know. > > On Sat, Oct 18, 2008 at 11:06 AM, Marritza <[EMAIL PROTECTED]> wrote: > > > Ok, let me clarify finally. (Never used newsgroups before so pardon > lack of > complete information :P ) > > class Design extends AppModel { > >var $primaryKey = 'designs_id'; >var $useTable = 'design'; > } > > class Status extends AppModel { > >var $primaryKey = 'status_id'; >var $useTable = 'status'; > } > > I'm not using foreign keys. The db schema has been posted in the first > message. > > > teknoid-3 wrote: > > > > > > If you cannot alter db structure, that's fine. Cake works perfectly > > well with legacy DB's, but you have to ensure that you specify any > > settings that do not follow conventions. That includes table names, > > primary keys as well as foreign keys. > > > > You didn't provide your model definitions, so it's hard to guess > as to > > what could be culprit. > > > > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: > >> Forgot to mention - I am using $prmaryKey syntax in each model, > because I > >> have limited possibilities to alter the db structure. Tho, it is > possible > >> for me to create a sample table using cake conventions, I'll try > again > >> then. > >> > >> > >> > >> teknoid-3 wrote: > >> > >> > You shouldn't break conventions when naming your primary keys. > >> > Cake will expect your primary key to be named 'id'... So > Design.id and > >> > Status.id. > >> > >> > Of course you can override those by setting a $prmaryKey = > 'myOwnKey'; > >> > in the model, but why make your life more difficult? > >> > >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: > >> >> Hello! > >> > >> >> I'm using Cake for several days now, I'm still under big > impression of > >> >> its > >> >> capabilities. > >> > >> >> Nevertheless, I have faced a problem, to which solution, which > I have > >> >> found, > >> >> feels not logical in the Cake ways of doing things. First, let > me show > >> >> you > >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian > Etch). > >> > >> >> table DESIGNS > >> >> designs_id serial <- primary key > >> >> job_name > >> >> status_id > >> >> ...etc > >> > >> >> table STATUS > >> >> status_id serial <- primary key > >> >> name > >> > >> >> The expected outcome is simple - I'm querying the Design model > to > >> >> retrieve > >> >> data about a job, and I expect to see the status name which is > related > >> >> thru > >> >> Design.status_id => Status.status_id. > >> > >> >> Now, when I tried to accomplish it with $hasOne in the Design > model > >> the > >> >> result is that Status is joined not on the forementioned > basis, but on > >> >> Design.design_id -> Status.status_id. > >> > >> >> to my surprise, it works using $belongsTo relation. > >> > >> >> Perhaps there is something wrong with my understanding of the > Cake > >> >> relation > >> >> ways, perhaps I'm simply overlooking some basic stuff. > >> > >> >> Anyhow, any help greatly appreciated. > >> > >> >> -- > >> >> View this message in > >> >> > >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418 > >> > ... > >> >> Sent from the CakePHP mailing list archive at Nabble.com. > >> > >> -- > >> View this message in > >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418 > >> > ... > >> Sent from the CakePHP mailing list archive at Nabble.com. > > > > > > > > > -- > View this message in context: > http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html > Sent from the CakePHP mailing list archive at Nabble.com. > > > > > > > -- > Join cleanscript.com Come here for professional PHP coding. > > > --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
> Yeah cake its strict on everything so you can't name your id "design_id" > stupid? Yes I know. Thank you for indicating that you have no idea what you're talking about. Go back to selling $70 websites and leave the rest of the internet in peace. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
Yeah cake its strict on everything so you can't name your id "design_id" stupid? Yes I know. On Sat, Oct 18, 2008 at 11:06 AM, Marritza <[EMAIL PROTECTED]> wrote: > > > Ok, let me clarify finally. (Never used newsgroups before so pardon lack of > complete information :P ) > > class Design extends AppModel { > >var $primaryKey = 'designs_id'; >var $useTable = 'design'; > } > > class Status extends AppModel { > >var $primaryKey = 'status_id'; >var $useTable = 'status'; > } > > I'm not using foreign keys. The db schema has been posted in the first > message. > > > teknoid-3 wrote: > > > > > > If you cannot alter db structure, that's fine. Cake works perfectly > > well with legacy DB's, but you have to ensure that you specify any > > settings that do not follow conventions. That includes table names, > > primary keys as well as foreign keys. > > > > You didn't provide your model definitions, so it's hard to guess as to > > what could be culprit. > > > > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: > >> Forgot to mention - I am using $prmaryKey syntax in each model, because > I > >> have limited possibilities to alter the db structure. Tho, it is > possible > >> for me to create a sample table using cake conventions, I'll try again > >> then. > >> > >> > >> > >> teknoid-3 wrote: > >> > >> > You shouldn't break conventions when naming your primary keys. > >> > Cake will expect your primary key to be named 'id'... So Design.id and > >> > Status.id. > >> > >> > Of course you can override those by setting a $prmaryKey = 'myOwnKey'; > >> > in the model, but why make your life more difficult? > >> > >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: > >> >> Hello! > >> > >> >> I'm using Cake for several days now, I'm still under big impression > of > >> >> its > >> >> capabilities. > >> > >> >> Nevertheless, I have faced a problem, to which solution, which I have > >> >> found, > >> >> feels not logical in the Cake ways of doing things. First, let me > show > >> >> you > >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). > >> > >> >> table DESIGNS > >> >> designs_id serial <- primary key > >> >> job_name > >> >> status_id > >> >> ...etc > >> > >> >> table STATUS > >> >> status_id serial <- primary key > >> >> name > >> > >> >> The expected outcome is simple - I'm querying the Design model to > >> >> retrieve > >> >> data about a job, and I expect to see the status name which is > related > >> >> thru > >> >> Design.status_id => Status.status_id. > >> > >> >> Now, when I tried to accomplish it with $hasOne in the Design model > >> the > >> >> result is that Status is joined not on the forementioned basis, but > on > >> >> Design.design_id -> Status.status_id. > >> > >> >> to my surprise, it works using $belongsTo relation. > >> > >> >> Perhaps there is something wrong with my understanding of the Cake > >> >> relation > >> >> ways, perhaps I'm simply overlooking some basic stuff. > >> > >> >> Anyhow, any help greatly appreciated. > >> > >> >> -- > >> >> View this message in > >> >> > >> context: > http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > >> >> Sent from the CakePHP mailing list archive at Nabble.com. > >> > >> -- > >> View this message in > >> context: > http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > >> Sent from the CakePHP mailing list archive at Nabble.com. > > > > > > > > > -- > View this message in context: > http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html > Sent from the CakePHP mailing list archive at Nabble.com. > > > > > -- Join cleanscript.com Come here for professional PHP coding. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
Ok, let me clarify finally. (Never used newsgroups before so pardon lack of complete information :P ) class Design extends AppModel { var $primaryKey = 'designs_id'; var $useTable = 'design'; } class Status extends AppModel { var $primaryKey = 'status_id'; var $useTable = 'status'; } I'm not using foreign keys. The db schema has been posted in the first message. teknoid-3 wrote: > > > If you cannot alter db structure, that's fine. Cake works perfectly > well with legacy DB's, but you have to ensure that you specify any > settings that do not follow conventions. That includes table names, > primary keys as well as foreign keys. > > You didn't provide your model definitions, so it's hard to guess as to > what could be culprit. > > On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: >> Forgot to mention - I am using $prmaryKey syntax in each model, because I >> have limited possibilities to alter the db structure. Tho, it is possible >> for me to create a sample table using cake conventions, I'll try again >> then. >> >> >> >> teknoid-3 wrote: >> >> > You shouldn't break conventions when naming your primary keys. >> > Cake will expect your primary key to be named 'id'... So Design.id and >> > Status.id. >> >> > Of course you can override those by setting a $prmaryKey = 'myOwnKey'; >> > in the model, but why make your life more difficult? >> >> > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: >> >> Hello! >> >> >> I'm using Cake for several days now, I'm still under big impression of >> >> its >> >> capabilities. >> >> >> Nevertheless, I have faced a problem, to which solution, which I have >> >> found, >> >> feels not logical in the Cake ways of doing things. First, let me show >> >> you >> >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). >> >> >> table DESIGNS >> >> designs_id serial <- primary key >> >> job_name >> >> status_id >> >> ...etc >> >> >> table STATUS >> >> status_id serial <- primary key >> >> name >> >> >> The expected outcome is simple - I'm querying the Design model to >> >> retrieve >> >> data about a job, and I expect to see the status name which is related >> >> thru >> >> Design.status_id => Status.status_id. >> >> >> Now, when I tried to accomplish it with $hasOne in the Design model >> the >> >> result is that Status is joined not on the forementioned basis, but on >> >> Design.design_id -> Status.status_id. >> >> >> to my surprise, it works using $belongsTo relation. >> >> >> Perhaps there is something wrong with my understanding of the Cake >> >> relation >> >> ways, perhaps I'm simply overlooking some basic stuff. >> >> >> Anyhow, any help greatly appreciated. >> >> >> -- >> >> View this message in >> >> >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> >> Sent from the CakePHP mailing list archive at Nabble.com. >> >> -- >> View this message in >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> Sent from the CakePHP mailing list archive at Nabble.com. > > > > -- View this message in context: http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20048173.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
If you cannot alter db structure, that's fine. Cake works perfectly well with legacy DB's, but you have to ensure that you specify any settings that do not follow conventions. That includes table names, primary keys as well as foreign keys. You didn't provide your model definitions, so it's hard to guess as to what could be culprit. On Oct 18, 7:45 am, Marritza <[EMAIL PROTECTED]> wrote: > Forgot to mention - I am using $prmaryKey syntax in each model, because I > have limited possibilities to alter the db structure. Tho, it is possible > for me to create a sample table using cake conventions, I'll try again then. > > > > teknoid-3 wrote: > > > You shouldn't break conventions when naming your primary keys. > > Cake will expect your primary key to be named 'id'... So Design.id and > > Status.id. > > > Of course you can override those by setting a $prmaryKey = 'myOwnKey'; > > in the model, but why make your life more difficult? > > > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: > >> Hello! > > >> I'm using Cake for several days now, I'm still under big impression of > >> its > >> capabilities. > > >> Nevertheless, I have faced a problem, to which solution, which I have > >> found, > >> feels not logical in the Cake ways of doing things. First, let me show > >> you > >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). > > >> table DESIGNS > >> designs_id serial <- primary key > >> job_name > >> status_id > >> ...etc > > >> table STATUS > >> status_id serial <- primary key > >> name > > >> The expected outcome is simple - I'm querying the Design model to > >> retrieve > >> data about a job, and I expect to see the status name which is related > >> thru > >> Design.status_id => Status.status_id. > > >> Now, when I tried to accomplish it with $hasOne in the Design model the > >> result is that Status is joined not on the forementioned basis, but on > >> Design.design_id -> Status.status_id. > > >> to my surprise, it works using $belongsTo relation. > > >> Perhaps there is something wrong with my understanding of the Cake > >> relation > >> ways, perhaps I'm simply overlooking some basic stuff. > > >> Anyhow, any help greatly appreciated. > > >> -- > >> View this message in > >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > >> Sent from the CakePHP mailing list archive at Nabble.com. > > -- > View this message in > context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
Forgot to mention - I am using $prmaryKey syntax in each model, because I have limited possibilities to alter the db structure. Tho, it is possible for me to create a sample table using cake conventions, I'll try again then. teknoid-3 wrote: > > > You shouldn't break conventions when naming your primary keys. > Cake will expect your primary key to be named 'id'... So Design.id and > Status.id. > > Of course you can override those by setting a $prmaryKey = 'myOwnKey'; > in the model, but why make your life more difficult? > > On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: >> Hello! >> >> I'm using Cake for several days now, I'm still under big impression of >> its >> capabilities. >> >> Nevertheless, I have faced a problem, to which solution, which I have >> found, >> feels not logical in the Cake ways of doing things. First, let me show >> you >> my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). >> >> table DESIGNS >> designs_id serial <- primary key >> job_name >> status_id >> ...etc >> >> table STATUS >> status_id serial <- primary key >> name >> >> The expected outcome is simple - I'm querying the Design model to >> retrieve >> data about a job, and I expect to see the status name which is related >> thru >> Design.status_id => Status.status_id. >> >> Now, when I tried to accomplish it with $hasOne in the Design model the >> result is that Status is joined not on the forementioned basis, but on >> Design.design_id -> Status.status_id. >> >> to my surprise, it works using $belongsTo relation. >> >> Perhaps there is something wrong with my understanding of the Cake >> relation >> ways, perhaps I'm simply overlooking some basic stuff. >> >> Anyhow, any help greatly appreciated. >> >> -- >> View this message in >> context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... >> Sent from the CakePHP mailing list archive at Nabble.com. > > > > -- View this message in context: http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20046244.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Newbie questions about model relations
You shouldn't break conventions when naming your primary keys. Cake will expect your primary key to be named 'id'... So Design.id and Status.id. Of course you can override those by setting a $prmaryKey = 'myOwnKey'; in the model, but why make your life more difficult? On Oct 17, 8:17 pm, Marritza <[EMAIL PROTECTED]> wrote: > Hello! > > I'm using Cake for several days now, I'm still under big impression of its > capabilities. > > Nevertheless, I have faced a problem, to which solution, which I have found, > feels not logical in the Cake ways of doing things. First, let me show you > my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). > > table DESIGNS > designs_id serial <- primary key > job_name > status_id > ...etc > > table STATUS > status_id serial <- primary key > name > > The expected outcome is simple - I'm querying the Design model to retrieve > data about a job, and I expect to see the status name which is related thru > Design.status_id => Status.status_id. > > Now, when I tried to accomplish it with $hasOne in the Design model the > result is that Status is joined not on the forementioned basis, but on > Design.design_id -> Status.status_id. > > to my surprise, it works using $belongsTo relation. > > Perhaps there is something wrong with my understanding of the Cake relation > ways, perhaps I'm simply overlooking some basic stuff. > > Anyhow, any help greatly appreciated. > > -- > View this message in > context:http://www.nabble.com/Newbie-questions-about-model-relations-tp200418... > Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newbie questions about model relations
Hello! I'm using Cake for several days now, I'm still under big impression of its capabilities. Nevertheless, I have faced a problem, to which solution, which I have found, feels not logical in the Cake ways of doing things. First, let me show you my table structure: (btw, I'm using PostgreSQL 8.3 on Debian Etch). table DESIGNS designs_id serial <- primary key job_name status_id ...etc table STATUS status_id serial <- primary key name The expected outcome is simple - I'm querying the Design model to retrieve data about a job, and I expect to see the status name which is related thru Design.status_id => Status.status_id. Now, when I tried to accomplish it with $hasOne in the Design model the result is that Status is joined not on the forementioned basis, but on Design.design_id -> Status.status_id. to my surprise, it works using $belongsTo relation. Perhaps there is something wrong with my understanding of the Cake relation ways, perhaps I'm simply overlooking some basic stuff. Anyhow, any help greatly appreciated. -- View this message in context: http://www.nabble.com/Newbie-questions-about-model-relations-tp20041894p20041894.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Some newbie questions part 1: showing form for a habtm relation
I gained a greater understanding about cakephp by baking my models, controllers and views, and analysing how cake does it by default. Maybe you should try this? Once you understand how cake does it, then it should be easier to figure out what cakes like and what you need to change to get it to work the way you want. Cheers, Adam On Dec 1, 8:36 am, Bram <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm baking my first CakePHP project at the moment and I've some newbie > questions. I'll ask each question in it's own topic. > > First of all, I've a model with an habtm relation, let's call this > model Company. The related model is called Specialty. I would like to > give users the possibility to select which specialties are applicable > for a company. I would prefer checkboxes, but I saw somewhere that a > select is used by default, that will also be fine for now. Anyway, > Could someone explain how to create a form for an habtm relation in > CakePHP 1.2.? > > Bram --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Some newbie questions part 1: showing form for a habtm relation
Hi all, I'm baking my first CakePHP project at the moment and I've some newbie questions. I'll ask each question in it's own topic. First of all, I've a model with an habtm relation, let's call this model Company. The related model is called Specialty. I would like to give users the possibility to select which specialties are applicable for a company. I would prefer checkboxes, but I saw somewhere that a select is used by default, that will also be fine for now. Anyway, Could someone explain how to create a form for an habtm relation in CakePHP 1.2.? Bram --~--~-~--~~~---~--~~ 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: Newbie questions
If you're not sure how to manage the layout structure yet, the last thing you need is medium/advanced tutorials. Cake is very simple to learn the basics of, and extremely powerful once you've gotten your head around the conventions. To be able to help, you'll need to say which version you're presently using: 1.1 is currently the stable release, but I use the 1.2 dev release because I want the very latest features and I know enough to be able to figure out what's going wrong when something does (which isn't all that often :)) In any case, feelexit's advice is slightly inaccurate. Under /app/views/layouts/, if you don't already have one, create a file called either default.thtml (for 1.1) or default.ctp (for 1.2). This is your basic layout file, whatever you put in this file will be output every time. There's more advanced things you can do with layouts, but for the moment I'd say don't worry about it, until you get the basics down. In this file you can indeed use the command feelexit mentions - but his post was slightly wrong in one respect. The command you want is renderElement('name_of_element'); ?> That doesn't help you right now though because you have no elements yet. You need to create them, under /app/views/elements/ - the filenames should all be something like name_of_element.thtml (for 1.1) or name_of_element.ctp (for 1.2). The name_of_element part is what you put in the renderElement command. For more dynamic content you may want to look into requestAction and components, but this is something I've barely scratched the surface of myself yet, so I can't give you any help there. --~--~-~--~~~---~--~~ 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: Newbie questions
make new file, header.thtml in hte component folder. and in ur layout, renderElement('header'); ?> --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newbie questions
Hello, I'm a newbie with CakePHP. How can I manage with layouta structure with a top menu, a main content and a right content ? Where I can find some medium / advanced tutorial for cakePHP ? Is it available an integration with the qooxdoo library (you find it on sourceforge) Luca --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Couple of newbie questions
First of all, my apologies for the 23839929th "newbie questions" topic ;) But I've been reading up on cakePHP the couple of last days now, and I've still some questions left which I'll like to answer before I really can start working on my project. Maybe some sort of background info could help, so here is some about me and what I'm trying to accomplish: My name is Ruud Bijnen, I'm 22 years old and live in the Netherlands. Although I've been scripting PHP for over 6 years now, I never had any proper education on computer science. All these years I've worked on little hobby projects, which didn't require to much work, so my experience with frameworks, MVC architecture and open source contribution is almost zero. The reason I'm now starting to use cakePHP is that I've taken on a more complex project, and didn't want to start from scratch, also it's a nice opportunity for me to learn about frameworks and a more professional way of scripting/programming. I live together with 13 other students in a nice student flat. Almost every day we have diner together, although not everyone will join everyday, we usually are with about 8 people. In order to keep costs for everyone fair we keep track of who's eating that day, and which costs are made, who paid for the food and who's next in line to prepare diner. For this we have a few forms and those results are weekly transformed into Excel sheets. (also we've paperwork for beer, snacks, chores and expenses (on household products etc.) My task is to automate those processes. Also there is going to be a nice little touch screen pc in the living room to be able to access al (or at least most of the) these tasks. And me and my housemates will be able to use a public website to access the app. // sorry for the way to long introduction, I'll try to keep it to the point My first question is: how to best separate the 2 different user interfaces? Not only has everything to be large on the touch screen console, the steps to accomplish something will be totally different in comparison to the 'public' website. So I can't just use two different style sheets. But the logic in the models (and probably the most in the controllers) will be identical, so two different cake apps probably isn't the best solution. This brings me to my second question: what sort of code belongs to the controller, and what to the model? The manual is imo not very consistent about this, and that confuses me. For example, in the models chapter they put some functions to a model, like: hide($id), unhide($id) and makeInactive($uid). This makes perfectly sense to me, but in "Example: Simple User Authentication" they just put every thing in the controller (even the password challenging, which imo should be part of the model). Third: what would you recommend, develop in 1.x.x.x or 1.2.x.x? I understand that it could take a while before the 1.2 branch reaches a RC/stable milestone, and that "it's done when it's done" or as Samuel DeVoreput it: "when it's done baking" ;). Personally I feel more like using 1.2, unless you would discourage that. Fourth, and hopefully last: there are a couple of authentication examples/methods out there, but what would the best to use at this point, or should I write my own? Like most programmers I don't like to reinvent the wheel. There are now a few auth modules I could chose from, but most are under heavy development, are abandoned, or lack proper documentation. I'll need a auth module where users can belong to multiple groups (because some housemates will be admin to a part of the app and some a few parts), but don't know which (if there is any). At this point I don't have a lot of experience with blogging or writing in general, but maybe at some point I'll try to write some about this project, and it's problems and solutions I came across. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---