Fixed SQL calls to be inline with with phpcs. Still need to move some sql to new joomla JDatabase.