Tuesday, October 4, 2011

Re: Simple deleteAll() yet I am stuck..

Thanks for the answer.. I did try your solution

$delCond['conditions'] = array('projects_id'=>
$projects_id,'project_modules_id'=>$projectModuleID);
$this->ProjectModule->UsersModule->deleteAll($delCond);

I am getting these error..

SQL Error: 1054: Unknown column 'conditions' in 'where clause' [CORE
\cake\libs\model\datasources\dbo_source.php, line 684]

Query: SELECT `UsersModule`.`id` FROM `users_modules` AS `UsersModule`
LEFT JOIN `project_modules` AS `ProjectModules` ON
(`UsersModule`.`project_modules_id` = `ProjectModules`.`id`) LEFT JOIN
`users` AS `Users` ON (`UsersModule`.`users_id` = `Users`.`id`) WHERE
conditions IN ('39', '27')

On Oct 4, 5:06 pm, Thomas Ploch <profipl...@googlemail.com> wrote:
> Hello,
> 1.) When posting a problem to the group, especially database related problems, posting the "some mysql error" is vital for us to help you.
> 2.) You are overwriting the conditions array in line 2 of your example:
> Try this instead (the 'AND' behavior is the default in cakephp, so you can safely ommit it):
> $delCond['conditions'] = array(
>     'projects_id'=>$projects_id,
>     'project_modules_id'=> $projectModuleID
> )
> Kind regards
> Thomas
> On 04.10.2011 13:31, sathyashrayan wrote:This is the query for deleting multiple row. $query = "DELETE FROM users_modules WHERE projects_id='$projects_id' AND project_modules_id='$projectModuleID'"; I tried this $delCond['conditions'] = array('projects_id'=>$projects_id); $delCond['conditions'] = array('AND'=>array('project_modules_id'=> $projectModuleID)); $this->ProjectModule->UsersModule->deleteAll($delCond); But the delete query is not working. It shows some mysql error as a select rather than delete. I am executing this in projects_module_controller.

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: