Fix database error when searching users

In the admin, when searching users, the database object
was referenced before assignment