Use JDatabase instead of MySQL queries