score:0

Accepted answer

ok, so here you are only counting, so perhaps you just need a variable of type long:

sql("select count(*) from user where tel = {telephonenumber}")
   .on('telephobenumber -> numberthatyoupassedtothemethod).executequery()
   .as(sqlparser.scalar[long].single)

you just totally changed the question, anyway, for the error you mentioned in the comment, the reason is that you have no connection as well as you did not define the database you want to use (default or otherwise). all the database calls are within the following block:

db.withconnection{
  implicit connection => 
     //sql queries live here. 
} 

moreover you need to db is injected if it is not the default database:

class mytestmodel @inject()(@nameddatabase("nondefaultdb") db: database){???}

follow mvc architecture: for consistency with model-view-controller architecture, all your database calls should be within models classes. the controller method needs to call the models method for the result.


Related Query

More Query from same tag