Re: Help with a naive delete problem
A, you are absolutely right !!! Mistake fixed. Thanks a lot to all of you. jbmere On 6 mar, 06:31, Sam Bernard sambern...@gmail.com wrote: Exactly. del is a deprecated function, so replace if ($this-Seccion-*del*($id)) { with if ($this-Seccion-*delete*($id)) { When a model function doesn't exist- cake tries to use it as sql, which is why del showed up as your sql query. -- 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
Help with a naive delete problem
Hello I'm just a beginner with CakePHP and I just made a model, a controller and I try to figure out the functionality. (see below the model and the controller) The problem I have is that when I push the button for delete a record the system ask if I like to delete the record #3. I say yes and an error happens The stack is: Debugger::handleError() - CORE/cake/libs/debugger.php, line 306 DboSource::showQuery() - CORE/cake/libs/model/datasources/ dbo_source.php, line 684 DboSource::execute() - CORE/cake/libs/model/datasources/ dbo_source.php, line 266 DboSource::fetchAll() - CORE/cake/libs/model/datasources/ dbo_source.php, line 410 DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php, line 364 Model::call__() - CORE/cake/libs/model/model.php, line 502 Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50 Seccion::del() - [internal], line ?? SeccionsController::delete() - APP/controllers/ seccions_controller.php, line 55 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 And the SQL is 'del'. This is surprising me Could you provide to me with some hits about where my mistake is ? Thanks in advance and sorry for disturb. I was having a look on different websites but finally i have no real ideas. === Model === ?php class Seccion extends AppModel { var $name = 'Seccion'; var $validate = array( 'seccion' = array('notempty') ); //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasMany = array( 'Medida' = array( 'className' = 'Medida', 'foreignKey' = 'seccion_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ) ); } ? = Controller ?php class SeccionsController extends AppController { var $name = 'Seccions'; var $helpers = array('Html', 'Form'); function index() { $this-Seccion-recursive = 0; $this-set('seccions', $this-paginate()); } function view($id = null) { if (!$id) { $this-Session-setFlash(__('Invalid Seccion.', true)); $this-redirect(array('action'='index')); } $this-set('seccion', $this-Seccion-read(null, $id)); } function add() { if (!empty($this-data)) { $this-Seccion-create(); if ($this-Seccion-save($this-data)) { $this-Session-setFlash(__('The Seccion has bee n saved', true)); $this-redirect(array('action'='index')); } else { $this-Session-setFlash(__('The Seccion could n ot be saved. Please, try again.', true)); } } } function edit($id = null) { if (!$id empty($this-data)) { $this-Session-setFlash(__('Invalid Seccion', true)); $this-redirect(array('action'='index')); } if (!empty($this-data)) { if ($this-Seccion-save($this-data)) { $this-Session-setFlash(__('The Seccion has bee n saved', true)); $this-redirect(array('action'='index')); } else { $this-Session-setFlash(__('The Seccion could n ot be saved. Please, try again.', true)); } } if (empty($this-data)) { $this-data = $this-Seccion-read(null, $id); } } function delete($id = null) { if (!$id) { $this-Session-setFlash(__('Invalid id for Seccion', tr ue)); $this-redirect(array('action'='index')); } if ($this-Seccion-del($id)) { $this-Session-setFlash(__('Seccion deleted', true)); $this-redirect(array('action'='index')); } } } ? -- 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
Re: Help with a naive delete problem
Use: $this-Seccion-*delete*($id) I'm pretty sure Model::del is deprecated. -- 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: Help with a naive delete problem
Hello First of all, thanks for giving the idea but, if you see the controller, the error comes when the code fired was: if ($this-Seccion-del($id)) { And this, in fact, your suggestion. The point is that, in this point $id is loaded with 3 which is the id of the id of the record to be deleted. The flash software asked if I'm sure about delete it in the right way but, inside, somewhere something wrong happens and I have no idea about it. Thank you so much for your help Jbmere On 4 mar, 05:14, jbmere jbm...@gmail.com wrote: Hello I'm just a beginner with CakePHP and I just made a model, a controller and I try to figure out the functionality. (see below the model and the controller) The problem I have is that when I push the button for delete a record the system ask if I like to delete the record #3. I say yes and an error happens The stack is: Debugger::handleError() - CORE/cake/libs/debugger.php, line 306 DboSource::showQuery() - CORE/cake/libs/model/datasources/ dbo_source.php, line 684 DboSource::execute() - CORE/cake/libs/model/datasources/ dbo_source.php, line 266 DboSource::fetchAll() - CORE/cake/libs/model/datasources/ dbo_source.php, line 410 DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php, line 364 Model::call__() - CORE/cake/libs/model/model.php, line 502 Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50 Seccion::del() - [internal], line ?? SeccionsController::delete() - APP/controllers/ seccions_controller.php, line 55 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 And the SQL is 'del'. This is surprising me Could you provide to me with some hits about where my mistake is ? Thanks in advance and sorry for disturb. I was having a look on different websites but finally i have no real ideas. === Model === ?php class Seccion extends AppModel { var $name = 'Seccion'; var $validate = array( 'seccion' = array('notempty') ); //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasMany = array( 'Medida' = array( 'className' = 'Medida', 'foreignKey' = 'seccion_id', 'dependent' = false, 'conditions' = '', 'fields' = '', 'order' = '', 'limit' = '', 'offset' = '', 'exclusive' = '', 'finderQuery' = '', 'counterQuery' = '' ) ); } ? = Controller ?php class SeccionsController extends AppController { var $name = 'Seccions'; var $helpers = array('Html', 'Form'); function index() { $this-Seccion-recursive = 0; $this-set('seccions', $this-paginate()); } function view($id = null) { if (!$id) { $this-Session-setFlash(__('Invalid Seccion.', true)); $this-redirect(array('action'='index')); } $this-set('seccion', $this-Seccion-read(null, $id)); } function add() { if (!empty($this-data)) { $this-Seccion-create(); if ($this-Seccion-save($this-data)) { $this-Session-setFlash(__('The Seccion has bee n saved', true)); $this-redirect(array('action'='index')); } else { $this-Session-setFlash(__('The Seccion could n ot be saved. Please, try again.', true)); } } } function edit($id = null) { if (!$id empty($this-data)) { $this-Session-setFlash(__('Invalid Seccion', true)); $this-redirect(array('action'='index')); } if (!empty($this-data)) { if ($this-Seccion-save($this-data)) { $this-Session-setFlash(__('The Seccion has bee n saved', true)); $this-redirect(array('action'='index')); } else { $this-Session-setFlash(__('The Seccion could n ot be saved. Please, try again.', true)); } } if (empty($this-data)) { $this-data = $this-Seccion-read(null, $id); } } function delete($id = null) { if (!$id) {
Re: Help with a naive delete problem
Exactly. del is a deprecated function, so replace if ($this-Seccion-*del*($id)) { with if ($this-Seccion-*delete*($id)) { When a model function doesn't exist- cake tries to use it as sql, which is why del showed up as your sql query. -- 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: Help with a naive delete problem
On Mar 5, 2011, at 23:31, Sam Bernard wrote: When a model function doesn't exist- cake tries to use it as sql, which is why del showed up as your sql query. As a still relative CakePHP newcomer, that sounds a strange thing to have built into the library; in what situations is that useful? -- 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