Your codes looks ok. Make sure $tentID is defined or have value otherwise it will give you an undefined variable tenantID, and sql syntax error .
RaeesIqbal commented: thanx, it was a problem also. +0
Resentful commented: Awesome solution! +1