开发者

Mysql delete query deletes only two columns in a row

I have a table with the following structure,

    FIELD           TYPE          EXTRA
faciltiy_id         int          auto_increment(Primary Key)
hotel_id            int
facility_title      varchar(20)
facility_desc      varchar(300)

When I want to delete a row with a particular facility_id I use the code,

DELETE 
FROM   $hotel_facilities
WH开发者_如何学运维ERE  facilities_id = '$facilities_id'";

But instead of the whole row, only the facility_title and facility_desc fields are getting deleted. If I run this query directly through phpmyadmin over the table it works correctly.

Can anyone enlighten me on what i am doing wrong?


But instead of the whole row, only the facility_title and facility_desc fields are getting deleted. If I run this query directly through phpmyadmin over the table it works correctly...

Because the facilities_id is an INT, you don't need to enclose it within single quotes:

DELETE FROM {$hotel_facilities}
 WHERE facilities_id = {$facilities_id}

But I think the real issue is that an UPDATE statement is being called, rather than the DELETE statement. Mainly because a DELETE statement only deletes entire rows, not specific columns.

You need to trace over what is being called when the submit is triggered, and print to screen (either using echo or via Javascript if it's more convenient) prior to execution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜