fix for notice found while QA of CRM-12348, and added a missing execute ...

1)The variable was incorrect which is been imploded, and thus throws notices (this variable is used to build WHERE clause of query).

2)I observed that after the $query initialization, the execute statement was missing.

The above two points are been fixed in this commit.