Bugfix: was calling mysql function in model. Changed to use the data layer instead.