Re: cascading deletes.
Sohei: thank you! :) It took me 2 min. to find the problem, after I had set the debug option to "2": 1 query took 1 ms NrQuery Error AffectedNum. rows Took (ms) 1 SELECT `File`.`id`, `File`.`name`, `File`.`type`, `File`.`size`, `File`.`data`, `File`.`created`, `File`.`modified` FROM `files` AS `File` WHERE (`File`.`id` = 2) LIMIT 1 1 1 1 HTTP/1.1 200 OK Date: Thu, 07 Sep 2006 21:01:19 GMT Server: Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_color PHP/5.1.4 X-Powered-By: PHP/5.1.4 Content-Length: 1314 Keep-Alive: timeout=5, max=96 Connection: Keep-Alive Content-Type: text/html Warning: Invalid argument supplied for foreach() in D:\download\1 - nyttige programmer\1 - Internet\development\xampp\htdocs\cake\cake\libs\model\model_php5.php on line 1019 Warning: Cannot modify header information - headers already sent by (output started at D:\download\1 - nyttige programmer\1 - Internet\development\xampp\htdocs\cake\cake\libs\model\model_php5.php:1019) in D:\download\1 - nyttige programmer\1 - Internet\development\xampp\htdocs\cake\cake\libs\controller\controller.php on line 401 2 queries took 0 ms Nr Query Error AffectedNum. rows Took (ms) 1 DELETE FROM `ccases_pictures` WHERE `id` = '2' 1 0 2 SELECT `File`.`id` FROM `files` AS `File` WHERE `File`.`ccases_picture_id` = '2'1054: Unknown column 'File.ccases_picture_id' in 'where clause' The File table does not have a ccases_picture_id field. I solved the problem by setting foreign key in the CcasesPictures model: class CcasesPicture extends AppModel { var $name = 'CcasesPicture'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasOne = array( 'File' => array('className' => 'File', 'conditions' => '', 'order' => '', 'foreignKey' => 'id', // <-- RIGHT HERE 'dependent' => true), ); } Best regards. Asbjørn Morell. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: cascading deletes.
If you are using same version of CakePHP as me (latest one:1.1.7.3363),then the error at line 1019 is with foreach and $records not being an array. $records = $model->findAll("$field = '$id'", $model->primaryKey, null, null); foreach($records as $record) { $model->del($record[$data['className']][$model->primaryKey]); }It seems to me that the findAll is return null, probably caused by sql errror somewhere. You might want to switch DEBUG to 2 to see sql queries executed, or check error log.Hope this help.Sohei --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: cascading deletes.
bump --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cascading deletes.
Does anyone have an idea why I get this error: # Warning: Invalid argument supplied for foreach() in D:download1 - nyttige programmer1 - Internetdevelopmentxampphtdocscakecakelibsmodelmodel_php5.php on line 1019 # # Warning: Cannot modify header information - headers already sent by (output started at D:download1 - nyttige programmer1 - Internetdevelopmentxampphtdocscakecakelibsmodelmodel_php5.php:1019) in D:download1 - nyttige programmer1 - Internetdevelopmentxampphtdocscakecakelibscontrollercontroller.php on line 401 I am trying to use cascading deletes - delete one CcasePicture and the corresponding file code: http://www.cakephp.org/pastes/show/c5f17064c8736b9ae73909cd455ff56e Best regards. Asbjørn Morell. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---