没有找到行时,MySQL SELECT语句不会停止

I expect this MySQL query to bomb out when it doesn't find the matching ID in the table:

mysql_query("SELECT * FROM table WHERE id='1' LIMIT 1") OR die("Boom!");

It doesn't. It just goes on processing with no error.

What am I missing here?

A select statement doesn't fail if it finds no rows - it just returns an empty result set.

You can check mysql_num_rows to see if any rows were found.

The sql statement does not fail, it actually returns nothing. Look here How does "do something OR DIE()" work in PHP?

A query only "fails" when you make a syntax or logical error in it.

A query returning no rows is still a valid query. Check the resultset that it returns to see how many results you get: in your case, check for there being '0'.

Run the query from the command line using the mysql command line client to make sure the table is not corrupted.