i am working on a Cakephp 2.x ...i want to delete a single record from the database i have a table in my database called Image .. which contain following fields.. idImage,User_id,filename,filesize,filemime
I would like to delete the single record with idImage=imageid
delete * from posts where imageid = 3'
i am doing this ..image id now has a value 4
$this->Image->imageId = $imageId;
if($this->Image->delete()){
echo "successfull";
}else{
echo "not";
}
but the code is not working .not deleting the record from db
imageId
. If you echo or printimageId
are you getting the correct value "4"? – bowleraeimageId
as the primary key in the model? By default Cake will useid
as the primary key. In your model writevar $primaryKey = 'imageId';
– bowlerae