I'm not sure if checking the return of $query_result$query_result
against empty()empty()
is meaningful, since the only indication query failed is if it returns FALSEFALSE
. Same for $affected_rows$affected_rows
, since the query may be successful but not necessary change any rows.
I'd suggest installing Devel module because it has a feature which records and prints all DB queries on a page load. This would enable you to see the actual query(ies).