Tree recover() method and alternative parent_id field
Hello, I'm trying to use the recover() method described here: http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::recover, unfortunately, whenever I run it I get the follow error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recover' at line 1 Is this a bug or would it appear I'm doing something wrong? Furthermore, I do not have a field called parent_id in my table, it is called idParent, is there anyway of forcing this field to be used? I can successfully run the find() function on my model without issue (i.e. $this-Category-find('all');) but not $this-Category-recover(); This is how I'm calling it, I've tried calling it directly from the CategoryController as well but that errors exactly the same. public function beforeRender() { $this-loadModel('Category'); $this-Category-recover(); } -- 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: Frontend Javascript framework
Check these out:AngularJS CakePHP Sample codehttp://hantsy.blogspot.ro/2013/11/angularjs-cakephp-sample-codes.html https://github.com/hantsy/angularjs-cakephp-sample/wiki marți, 10 decembrie 2013, 05:17:13 UTC+2, Wey a scris: Hi there, This isn't a specific CakePHP question so I apologize in advance if this isn't the appropriate group to ask this question. I have been developing in Cake for quite some time now (over two years), and I am trying to build an application where the frontend will use REST calls to render the data to the user. I have been researching about frontend JS frameworks and I found that Angular.js stands up among the others, but its biggest drawback for me is not being SEO-friendly which is a killer for my app's requirements. So I ask you guys on recommendations in developing an isomorphic application in Javascript with Cake as the backend. Thanks! -- 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.
Date modified isn't null when adding a record
Normally, when you add a record with a form to a database table, CakePHP will automatically fill in the created field in de database with the current date time. It works for my table called attractions (model Attraction). But now, strange things are happening. When I add a record for: - model AttractionProperty, table attraction_properties - model AttractionTypes, table attraction_types - model AttractionPropertyLink, table attraction_properties_links - ... ... both the fields created and modified are filled in. I checked if the id of my model is set in the add action ($this-request-id), but it says false. Here's my controller code: public function add() { if ($this-request-is('post')) { $this-AttractionProperty-create(); if ($this-AttractionProperty-save($this-request-data)) { // data array opslaan $this-Session-setFlash(__('De eigenschap werd succesvol toegevoegd.'), 'default', array( 'class' = 'alert alert-success' )); return $this-redirect(array( 'action' = 'index' )); } $this-Session-setFlash(__('Er is een fout tijdens het toevoegen van de eigenschap opgetreden.'), 'default', array( 'class' = 'alert alert-danger' )); } } public function edit($id = null) { if (!$id) { throw new NotFoundException(__('Ongeldige eigenschap.')); } $property = $this-AttractionProperty-findById($id); if (!$property) { throw new NotFoundException(__('Ongeldige eigenschap.')); } if ($this-request-is(array('post', 'put'))) { $this-AttractionProperty-id = $id; if ($this-AttractionProperty-save($this-request-data)) { // data array opslaan $this-Session-setFlash(__('De eigenschap werd succesvol bewerkt.'), 'default', array( 'class' = 'alert alert-success' )); return $this-redirect(array( 'action' = 'index' )); } $this-Session-setFlash(__('Er is een fout tijdens het bewerken van de eigenschap opgetreden.'), 'default', array( 'class' = 'alert alert-danger' )); } if (!$this-request-data) { $this-request-data = $property; } } I did read http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-save-array-data-null-boolean-validate-true-array-fieldlist-array to retrieve more info, but it seems that I've done everything to the rules. I also know that you can do if ($this-AttractionProperty-save($this-request-data(array('modified' = false { } when you save in the add action, but I realy want to know what's the underlying problem ;) Is this a common problem or what could be the reason of this behavior? -- 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: Date modified isn't null when adding a record
Well, that is not strange, that is exactly how it is supposed to be adding a record is also a type of modification if you need to know if the record has been modified yet, compare created and modified. if they are equal the records have not been yet modified. mark Am Sonntag, 9. Februar 2014 15:46:34 UTC+1 schrieb Sam Clauw: Normally, when you add a record with a form to a database table, CakePHP will automatically fill in the created field in de database with the current date time. It works for my table called attractions (model Attraction). But now, strange things are happening. When I add a record for: - model AttractionProperty, table attraction_properties - model AttractionTypes, table attraction_types - model AttractionPropertyLink, table attraction_properties_links - ... ... both the fields created and modified are filled in. I checked if the id of my model is set in the add action ($this-request-id), but it says false. Here's my controller code: public function add() { if ($this-request-is('post')) { $this-AttractionProperty-create(); if ($this-AttractionProperty-save($this-request-data)) { // data array opslaan $this-Session-setFlash(__('De eigenschap werd succesvol toegevoegd.'), 'default', array( 'class' = 'alert alert-success' )); return $this-redirect(array( 'action' = 'index' )); } $this-Session-setFlash(__('Er is een fout tijdens het toevoegen van de eigenschap opgetreden.'), 'default', array( 'class' = 'alert alert-danger' )); } } public function edit($id = null) { if (!$id) { throw new NotFoundException(__('Ongeldige eigenschap.')); } $property = $this-AttractionProperty-findById($id); if (!$property) { throw new NotFoundException(__('Ongeldige eigenschap.')); } if ($this-request-is(array('post', 'put'))) { $this-AttractionProperty-id = $id; if ($this-AttractionProperty-save($this-request-data)) { // data array opslaan $this-Session-setFlash(__('De eigenschap werd succesvol bewerkt.'), 'default', array( 'class' = 'alert alert-success' )); return $this-redirect(array( 'action' = 'index' )); } $this-Session-setFlash(__('Er is een fout tijdens het bewerken van de eigenschap opgetreden.'), 'default', array( 'class' = 'alert alert-danger' )); } if (!$this-request-data) { $this-request-data = $property; } } I did read http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-save-array-data-null-boolean-validate-true-array-fieldlist-array to retrieve more info, but it seems that I've done everything to the rules. I also know that you can do if ($this-AttractionProperty-save($this-request-data(array('modified' = false { } when you save in the add action, but I realy want to know what's the underlying problem ;) Is this a common problem or what could be the reason of this behavior? -- 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: Date modified isn't null when adding a record
Okay, that's totally clear to me now. At first sight, I thought there shouldn't be a date modified when adding a record. But that's the second system that do save a date create and a date modified when adding a record. Thanks 4 the clarification! -- 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: Frontend Javascript framework
Go for JavascriptMVC ..work perfectly with CakePHP REST On Sun, Feb 9, 2014 at 12:29 AM, MihaiTL maft...@gmail.com wrote: Check these out:AngularJS CakePHP Sample codehttp://hantsy.blogspot.ro/2013/11/angularjs-cakephp-sample-codes.html https://github.com/hantsy/angularjs-cakephp-sample/wiki marți, 10 decembrie 2013, 05:17:13 UTC+2, Wey a scris: Hi there, This isn't a specific CakePHP question so I apologize in advance if this isn't the appropriate group to ask this question. I have been developing in Cake for quite some time now (over two years), and I am trying to build an application where the frontend will use REST calls to render the data to the user. I have been researching about frontend JS frameworks and I found that Angular.js stands up among the others, but its biggest drawback for me is not being SEO-friendly which is a killer for my app's requirements. So I ask you guys on recommendations in developing an isomorphic application in Javascript with Cake as the backend. Thanks! -- 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. -- Abhijit Kakade LAMP Developer, MCP,CCNA Mob : +91-9923729250 -- 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.
Paginator isn't sorting
I would like to sort my index list on sequence ASC, but it won't work. If I see the query setup in the CakePHP docs (http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html#query-setup), my paginator settings should look like this: public function index() { $this-Paginator-settings = array( 'Attraction' = array( 'conditions' = array( 'Attraction.deleted' = null ), 'order' = array( 'Attraction.sequence ASC', 'Attraction.id ASC' ), 'limit' = 15 ) ); $attractions = $this-Paginator-paginate('Attraction'); $this-set('attractions', $attractions); } But every time I load my index file, the list is sorted on ID. My HTML sorting links above do work and I'm very happy with that: div class=collapse navbar-collapse id=bs-example-navbar-collapse-1 ul class=nav navbar-nav li?php echo $this-Paginator-sort('id', 'id'); ?/li li?php echo $this-Paginator-sort('name', 'naam'); ?/li li?php echo $this-Paginator-sort('show', 'zichtbaarheid'); ?/li li?php echo $this-Paginator-sort('sequence', 'gewicht'); ?/li /ul /div So can anybody tell me if there's anything wrong with my order item in my paginator settings? ;) Thx! -- 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 2 Custom Route Class
Thanks!! Worked a treat :) On Saturday, February 8, 2014 4:04:47 AM UTC+8, José Lorenzo wrote: The casing of folders and files changed from 1.3 to 2.x Please read the migration guide for a complete list of differences http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#file-and-folder-naming. You may also want to execute the automated upgrade shell that helps you with some of the migration tasks. On Friday, February 7, 2014 3:51:53 PM UTC+1, Patrick Templeman Twells wrote: Hi, in Cake 1.3 I had a custom route class set up which looked as follows: /app/libs/routes/slug_route.php ?php class SlugRoute extends CakeRoute { function parse($url) { $params = parent::parse($url); if (empty($params)) { return false; } $slugs = Cache::read('dp_slugs'); if (empty($slugs) || !array_key_exists($params['slug'], $slugs)) { App::import('Model', 'DynamicPage'); $DynamicPage = new DynamicPage(); $pages = $DynamicPage-find('all', array( 'fields' = array('DynamicPage.url_slug'), 'recursive' = -1 )); $slugs = array_flip(Set::extract('/DynamicPage/url_slug', $pages)); Cache::write('dp_slugs', $slugs); } if (isset($slugs[$params['slug']])) { return $params; } return false; } } ? I've just set up a Cake 2 website and this just tells me: Route class not found, or route class is not a subclass of CakeRoute Error: An Internal Error Has Occurred. I'm trying to find an example of a custom route for url_slugs that works but I can't get it working. Any ideas what I need to update to make it work? Based on what I've been able to find, I've updated it so that now the class is in /app/Lib/Routing/Route/slug_route.php and looks like this: ?php /** * Deal with URL Slugs */ App::uses('DynamicPage', 'Model'); App::uses('CakeRoute', 'Routing/Route'); class CategorySlugRoute extends CakeRoute { /** * Parse the URL * @param string $url * @return boolean */ function parse($url) { $params = parent::parse($url); if (empty($params)) { return false; } // See if slugs are cached $slugs = Cache::read('dp_slugs'); if (!$slugs) { // Get all slugs $DynamicPage = new DynamicPage(); $slugs = $DynamicPage-find('list', array( 'fields' = array('DynamicPage.url_slug'), 'recursive' = -1 )); Cache::write('dp_slugs', $slugs); } // Reverse slugs for easy comparison $slugs = array_flip($slugs); // See if dynamic pages have been passed if (!empty($params['pass'])) { $params['slug'] .= '/' . implode('/', $params['pass']); } // Match passed slug with Category slugs if (isset($slugs[$params['slug']])) { return $params; } return FALSE; } } in /app/config/routes.php I have this at the end of the file: App::uses('SlugRoute', 'Routing/Route'); Router::connect('/:slug', array('controller' = 'dynamic_pages', 'action' = 'view'), array('routeClass' = 'SlugRoute')); But I still have the error. Any ideas would be greatly appreciated Thanks! Patrick -- 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.