Re: Comparable 2.xx to 3.xx functionality
Hey Dave, 1. Assuming you are in the UsersController and what to get the value of a single field of users with $id: $tempKey =$this-Users-get($id, ['fields' = ['temp_key']])-tempKey; While this is more verbose that 2.x was, I believe this is for the better. You can quite easily implement a field method for your tables. 2. CakePHP 2.x is (Assuming UsersController): $this-User-set($this-request-data); if ($this-User-validates(array('fieldList' = array('email' { } CakePHP 3.x is (Assuming UsersController): $userEntity = $this-Users-newEntity($this-request-data); if ($this-Users-validate($userEntity, ['email'])) { } Or: $validator = new \Cake\Validation\Validator(); $validator-add('email', ['rule' = 'email']); $errors = $validator-errors($this-request-data); Which, while more verbose, allows you to very easily create transient validation rules without needing to touch the ORM layer. The Cake 3 ORM layer is far more complex than the old Cake 2.x model layer, however, this extra complexity makes it far more powerful. You can literally build any SQL statement you want without ever having to write a single line of SQL. As for the switch to Square brackets, Cake 3 requires PHP 5.4, and [] is quicker to write than array(), so it makes sense. And the namespacing and use's is a small price to pay for the benefits that namespaces provide. Hope this clarifies things for you! On Sunday, 21 September 2014 22:48:10 UTC+2, Dave Edwards wrote: Thanks, I thought that this is where I may get some help over the new 'features' or ways of working in 3.xx, that I do not understand, and not told to go and read up on PHP - that's actually quite dismissive and patronising. What I actually need to understand is what you've done to Cake 3.xx. because I do not understand your new documentation - sorry for being so thick. I may be mistaken, but I thought that cake got it's name because using the framework was a 'piece of cake' i.e. simple to use - I'm afraid as a user of cake that this is no longer the case :( I do understand 2.xx and its' documentation... not 3.xx A a couple of examples, in 2.xx I could do this $key = $this-User-field('temp_key') now I have to do this /* something else needs to go here, but I haven't worked it out yet because I keep getting errors*/ $key = $users-find()-extract('temp_key') another example is that I could do this if ($this-User-validates(array('fieldList' = array('email' { } now I have to do this $users = TableRegistry::get('Users'); $user = $users-newEntity($this-request-data()); $valid = $users-validate($user, ['email']); if ($valid) { } Is this progress? With regards to square brackets, (now that I've looked it up), you could have simply said that in PHP 5.4 square brackets are a short syntax for array(), and whilst the old method will not be removed, we've decide to use them. I would have understood that - so I'm obviously not that thick. If we were all programmers to your standard, we wouldn't need to use a framework, but a framework *should* remove the hard work... Thanks for the reply. Dave On Sunday, 21 September 2014 21:03:00 UTC+1, José Lorenzo wrote: I think to read a bit more of how php works, it will help you understand much better how to work with CakePHP. I don't know a good tutorial for learning PHP, though. You can also google about the new features in the language since PHP 5.3, specially the changes in 5.4 since you look confused about the use of square brackets. On Sunday, September 21, 2014 7:43:03 PM UTC+2, Dave Edwards wrote: Thanks, but neither seem to work... You suggested, $allTitles = $articles-find()-extract('title'); I tried $users-find()-extract('temp_key') but gives an error of Call to a member function find() on a non-object You suggested $this-User-validates(array('fieldList' = array('email', 'password'))) I tried $this-User-validates(array('fieldList' = array('email'))) but gives an error of Unknown method quot;validatesquot; I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know? In fact, I've just found an entry on validating in controllers in ' http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in 'http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it! Dave On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote: There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' =
Comunidade Brasileira
Olá bom dia, tenho um projeto pessoal que desenvolvi com o cakePHP, www.tabletenniscoreboard.com/system é possível navegar nele criando uma conta no Facebook, com o projeto bem encaminhado tem alguém em São Paulo com disponibilidade para conversar, pois tenho um desenho de estrutura do que eu preciso para complementar o que eu fiz, pois tenho um aplicativo mobile eu encaixará neste projeto! Se alguém tiver um portfólio legal, é só enviar pois ficarei grato! grato Léo -- 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/d/optout.
Re: Comparable 2.xx to 3.xx functionality
Sorry, Dave, that was not my intention. I invited you to read about the changes in PHP since the square brackets have been around for some time and I think it could be good if you get up to date with all the new goodies PHP has to offer you a a developer. It only takes around 10 minutes to read from the PHP official docs. On Sunday, September 21, 2014 10:48:10 PM UTC+2, Dave Edwards wrote: Thanks, I thought that this is where I may get some help over the new 'features' or ways of working in 3.xx, that I do not understand, and not told to go and read up on PHP - that's actually quite dismissive and patronising. What I actually need to understand is what you've done to Cake 3.xx. because I do not understand your new documentation - sorry for being so thick. I may be mistaken, but I thought that cake got it's name because using the framework was a 'piece of cake' i.e. simple to use - I'm afraid as a user of cake that this is no longer the case :( I do understand 2.xx and its' documentation... not 3.xx A a couple of examples, in 2.xx I could do this $key = $this-User-field('temp_key') now I have to do this /* something else needs to go here, but I haven't worked it out yet because I keep getting errors*/ $key = $users-find()-extract('temp_key') another example is that I could do this if ($this-User-validates(array('fieldList' = array('email' { } now I have to do this $users = TableRegistry::get('Users'); $user = $users-newEntity($this-request-data()); $valid = $users-validate($user, ['email']); if ($valid) { } Is this progress? With regards to square brackets, (now that I've looked it up), you could have simply said that in PHP 5.4 square brackets are a short syntax for array(), and whilst the old method will not be removed, we've decide to use them. I would have understood that - so I'm obviously not that thick. If we were all programmers to your standard, we wouldn't need to use a framework, but a framework *should* remove the hard work... Thanks for the reply. Dave On Sunday, 21 September 2014 21:03:00 UTC+1, José Lorenzo wrote: I think to read a bit more of how php works, it will help you understand much better how to work with CakePHP. I don't know a good tutorial for learning PHP, though. You can also google about the new features in the language since PHP 5.3, specially the changes in 5.4 since you look confused about the use of square brackets. On Sunday, September 21, 2014 7:43:03 PM UTC+2, Dave Edwards wrote: Thanks, but neither seem to work... You suggested, $allTitles = $articles-find()-extract('title'); I tried $users-find()-extract('temp_key') but gives an error of Call to a member function find() on a non-object You suggested $this-User-validates(array('fieldList' = array('email', 'password'))) I tried $this-User-validates(array('fieldList' = array('email'))) but gives an error of Unknown method quot;validatesquot; I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know? In fact, I've just found an entry on validating in controllers in ' http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in 'http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it! Dave On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote: There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' = array('email', 'password'))) Yes your controller looks just about right and it is very easy to understand what to expect as I read further. HTH T On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards goo...@bubbletoonz.com wrote: Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use
Re: 3.0: Entity get/set mutators
Don't use accessors for formatting your columns to be displayed in the view. The accessors are meant to get the data as it should be saved in the database. You can use instead a virtual field such as active_status: protected function _activeStatus() { return $this-active ? 'Active' : 'Inactive'; } echo $entity-active_status; On Sunday, September 21, 2014 11:45:33 PM UTC+2, Joe Theuerkauf wrote: i have several tables with an `active` column, and the Admin should be able to de/activate records to determine whether they related records are available in the application. Instead of constantly converting T/F or 1/0 to Active/Inactive, i wrote an Entity getter: protected function _getActive($active) { return $active ? 'Active' : 'Inactive'; } That's been working pretty well. The Entity-active property always provides the string. The problem is updating the data: SomeTableController gets a request like */some_table/active/2/1* to set ID 2 active (1): public function active($id, $active) { $entity = $this-SomeTable-get($id); $entity-active = $active; if ($this-SomeTable-save($entity)) { // Success! } else { // Fail! } } The problem: save() reports a successful save, but the database isn't updated. Scratch that: the `modified` column is updated, but not the `active` flag. If i kill _getActive() the update works, but i lose the convenience of the string representation. My *guess* is, i need a setter to handle the switch, but i'm not sure exactly how they work. The documentation ( http://book.cakephp.org/3.0/en/orm/entities.html#Cake\ORM\Entity::set) for set mutators shows an example of setting some *other* entity property ('slug') using the 'title' property. But there's no example for mutating the property being called, and i don't know if that even makes sense... Along with no _setActive mutator, i also tried the following: protected function _setActive($active) { // $this-set('active', $active); -- Created loop condition fatal error. $this-_properties['active'] = $active; return $active; } No luck. It does the same as no setter: updates the entity (with updated active modified properties), but save() doesn't write the changed active property to the database. Any help? Thanks. -joe t. -- 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/d/optout.
Re: When do views render?
The documentation is correct, the view s rendered as soon as the controller function that was invoked returns or reaches the last line. You can make it render earlier by calling $this-render() On Sunday, September 21, 2014 8:34:26 PM UTC+2, James Gaston wrote: While trying to track down an error in a UsersController method: Notice (8): Undefined index: User [APP/Controller/UsersController.php, line ...] I've come back to an issue that has yet to clarify in my head, specifically, the line in the cakephp v2 controller documentation that says: ... once a controller action has completed, CakePHP will handle rendering and delivering the View. Seems to me this line in the documentation is incorrect. In fact, a controller renders a view and then control may return to the same controller method to process any form date submitted by the view. Am I wrong in my thinking? - James -- 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/d/optout.
cant add new record in HABTM table
I want to add a new record in a table called TutorsSubject. This table is created from HABTM relationship of Tutor and Subject. Anyway I load the subject names in a text box and I can select a subject name but I cant add a new record. I need to set the id of the tutor_id. There are 3 fields in the tutorsSubject table called id,tutor_id and subject_id. I only need to select in 1 field which is the subject_id from a list of names found in the subject table, and then set the tutor_id manually. Currently I am able to select from a list of subject names but I cant add a new record with the subject name and set tutor_id. Error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails class TutorsSubjectsController extends AppController { public function tutoradd() { $this-loadModel('Subject'); $options['recursive']=-1; $options['fields']=array('Subject.name'); $te2= $this-Subject-find('list',$options); debug($te2); $this-set( 'te',$te2); //put is for edit and post for new record if ($this-request-is('post')) { $this-request-data['TutorsSubject']['tutor_id']=2; debug($this-request-data); if ($this-TutorsSubject-save($this-request-data)) { $this-Session-setFlash(__('Your post has been updated.')); return $this-redirect(array('controller' = 'tutors','action' = 'tutordetails')); } $this-Session-setFlash(__('Unable to update your post.')); } //View which works fine as it displays the list echo $this-Form-create('TutorsSubject', array('type' = 'post')); echo $this-Form-input('tutorsSubject.subject_id', array('options' = $te)); echo $this-Form-end('Save Post'); -- 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/d/optout.
Angular/Polymer web components and CakePHP
Canvassing some opinion... I'm just about to start a project that has an Angular and/or Polymer web components front end, so the API only ever needs to send JSON responses and receive normal posts/get requests. As such, there is no need for the 'V' part of an MVC framework. I know CakePHP can do this very well (I've already built one) but is it still considered the best/an ideal framework for this purpose? -- 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/d/optout.
Re: cant add new record in HABTM table
Hvae you tried saveAll($dataArray, array('deep' = true)); ? I use this method to save all my HABTM data. Also, since you are manually setting data maybe, your array is not well formed for CakePHP save(All). Anup On Monday, 22 September 2014 14:21:03 UTC+5:30, ajt wrote: I want to add a new record in a table called TutorsSubject. This table is created from HABTM relationship of Tutor and Subject. Anyway I load the subject names in a text box and I can select a subject name but I cant add a new record. I need to set the id of the tutor_id. There are 3 fields in the tutorsSubject table called id,tutor_id and subject_id. I only need to select in 1 field which is the subject_id from a list of names found in the subject table, and then set the tutor_id manually. Currently I am able to select from a list of subject names but I cant add a new record with the subject name and set tutor_id. Error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails class TutorsSubjectsController extends AppController { public function tutoradd() { $this-loadModel('Subject'); $options['recursive']=-1; $options['fields']=array('Subject.name'); $te2= $this-Subject-find('list',$options); debug($te2); $this-set( 'te',$te2); //put is for edit and post for new record if ($this-request-is('post')) { $this-request-data['TutorsSubject']['tutor_id']=2; debug($this-request-data); if ($this-TutorsSubject-save($this-request-data)) { $this-Session-setFlash(__('Your post has been updated.')); return $this-redirect(array('controller' = 'tutors','action' = 'tutordetails')); } $this-Session-setFlash(__('Unable to update your post.')); } //View which works fine as it displays the list echo $this-Form-create('TutorsSubject', array('type' = 'post')); echo $this-Form-input('tutorsSubject.subject_id', array('options' = $te)); echo $this-Form-end('Save Post'); -- 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/d/optout.
Re: cant add new record in HABTM table
But I dont need a saveall as I save to 1 table only ? Saveall is not appropriate for this. I am not sure what to do here. -- 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/d/optout.
Re: 3.0: Entity get/set mutators
That did the trick. Small correction: _getActiveStatus worked for me in the Entity class, _activeStatus didn't display anything. Thank you! -joe On Monday, 22 September 2014 04:42:23 UTC-4, José Lorenzo wrote: Don't use accessors for formatting your columns to be displayed in the view. The accessors are meant to get the data as it should be saved in the database. You can use instead a virtual field such as active_status: protected function _activeStatus() { return $this-active ? 'Active' : 'Inactive'; } echo $entity-active_status; On Sunday, September 21, 2014 11:45:33 PM UTC+2, Joe Theuerkauf wrote: i have several tables with an `active` column, and the Admin should be able to de/activate records to determine whether they related records are available in the application. Instead of constantly converting T/F or 1/0 to Active/Inactive, i wrote an Entity getter: protected function _getActive($active) { return $active ? 'Active' : 'Inactive'; } That's been working pretty well. The Entity-active property always provides the string. The problem is updating the data: SomeTableController gets a request like */some_table/active/2/1* to set ID 2 active (1): public function active($id, $active) { $entity = $this-SomeTable-get($id); $entity-active = $active; if ($this-SomeTable-save($entity)) { // Success! } else { // Fail! } } The problem: save() reports a successful save, but the database isn't updated. Scratch that: the `modified` column is updated, but not the `active` flag. If i kill _getActive() the update works, but i lose the convenience of the string representation. My *guess* is, i need a setter to handle the switch, but i'm not sure exactly how they work. The documentation ( http://book.cakephp.org/3.0/en/orm/entities.html#Cake\ORM\Entity::set) for set mutators shows an example of setting some *other* entity property ('slug') using the 'title' property. But there's no example for mutating the property being called, and i don't know if that even makes sense... Along with no _setActive mutator, i also tried the following: protected function _setActive($active) { // $this-set('active', $active); -- Created loop condition fatal error. $this-_properties['active'] = $active; return $active; } No luck. It does the same as no setter: updates the entity (with updated active modified properties), but save() doesn't write the changed active property to the database. Any help? Thanks. -joe t. -- 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/d/optout.
Re: Angular/Polymer web components and CakePHP
You mean should you learn an entire new framework so that you could have one layer less :D Whenever I get such projects the temptation is strong to go with some of the so called REST api frameworks but I keep coming back to cake for the familiarity and flexibility. Imaging if you did want a V layer at a later date... Just my 2c T On Mon, Sep 22, 2014 at 2:27 PM, Jeremy Burns jeremybu...@classoutfit.com wrote: Canvassing some opinion... I'm just about to start a project that has an Angular and/or Polymer web components front end, so the API only ever needs to send JSON responses and receive normal posts/get requests. As such, there is no need for the 'V' part of an MVC framework. I know CakePHP can do this very well (I've already built one) but is it still considered the best/an ideal framework for this purpose? -- 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/d/optout. -- = Hire a CakePHP dev team : http://sanisoft.com = -- 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/d/optout.
Re: Angular/Polymer web components and CakePHP
Good thoughts. The downside of familiarity, of course, is that I could be missing out on something better by sticking to what I know best. You are right about the V layer though. On 22 Sep 2014, at 12:52, Dr. Tarique Sani tariques...@gmail.com wrote: You mean should you learn an entire new framework so that you could have one layer less :D Whenever I get such projects the temptation is strong to go with some of the so called REST api frameworks but I keep coming back to cake for the familiarity and flexibility. Imaging if you did want a V layer at a later date... Just my 2c T On Mon, Sep 22, 2014 at 2:27 PM, Jeremy Burns jeremybu...@classoutfit.com wrote: Canvassing some opinion... I'm just about to start a project that has an Angular and/or Polymer web components front end, so the API only ever needs to send JSON responses and receive normal posts/get requests. As such, there is no need for the 'V' part of an MVC framework. I know CakePHP can do this very well (I've already built one) but is it still considered the best/an ideal framework for this purpose? -- 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/d/optout. -- = Hire a CakePHP dev team : http://sanisoft.com = -- 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/d/optout. -- 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/d/optout.
Re: cant add new record in HABTM table
Oh Ok. Now I see what are you doing. If you check the documentation for Cakephp, the association tables gets populated by Cakephp, itself. Howvever if you are saving the data straight into the association tble then do it this way $data['tutor_id'] = 2; $data['subject_id'] = $this-request-data['Subject']['id]; $this-TutorsSubject-save($data); As note of caution make sure that both foreign key ID's have there respective rows in parent tables before saving saving as your original error is MySQL error for data integrity... On Monday, 22 September 2014 16:40:14 UTC+5:30, ajt wrote: But I dont need a saveall as I save to 1 table only ? Saveall is not appropriate for this. I am not sure what to do here. -- 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/d/optout.
How encrypt IDs
I use this type URL to edit records: /edit/1 where 1 is the ID of the record. I want to know how implement this type URL: /edit/7aSes77Gb642r8dx-patPQ08xC6VdZsydO31zA3mVLQ Best wishes. -- 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/d/optout.
Re: How encrypt IDs
Hi If you aren't planning on making any of these urls humanly parseable / bookmarkable, how about just having an path such as /edit/ I've been working on a ordering system which when i first select the record to edit i set the id into a session and then just use that on my edit pages. if you are looking for something bookmarkable but just don't want numerical ids, perhaps look at implementing UUID According to the book: Rather than using an auto-increment key as the primary key, you may also use char(36). CakePHP will then use a unique 36 character UUID (String::uuid) whenever you save a new record using the Model::save method. http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html Regards Mike On 22 Sep 2014, at 15:48, romel javier gomez herrera bmxquiksilver7...@gmail.com wrote: I use this type URL to edit records: /edit/1 where 1 is the ID of the record. I want to know how implement this type URL: /edit/7aSes77Gb642r8dx-patPQ08xC6VdZsydO31zA3mVLQ Best wishes. -- 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/d/optout. Mike Karthäuser Director, Brightstorm Ltd. 1, Brewery Court North Street Bristol BS3 1JS mi...@brightstorm.co.uk www.brightstorm.co.uk +44(0) 7939252144 -- 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/d/optout.
I share one example to manage nested categories with CakePHP
Demo: http://jqtreecakephpexample-theteacher.rhcloud.com/ Code: https://github.com/romelgomez/jqtree-cakephp-openshift-example -- 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/d/optout.
Re: How encrypt IDs
Hi Javier, take a look at http://hashids.org/php/ Hth Jan On 22. September 2014 16:48:06 MESZ, romel javier gomez herrera bmxquiksilver7...@gmail.com wrote: I use this type URL to edit records: /edit/1 where 1 is the ID of the record. I want to know how implement this type URL: /edit/7aSes77Gb642r8dx-patPQ08xC6VdZsydO31zA3mVLQ Best wishes. -- 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/d/optout. -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. -- 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/d/optout.