Sugarcrm check sql query error