mysql - Need example of use of PreparedStatement with Anorm scala -


i using anorm querying mysql database playframework 2.1. created prepared statement this.

import play.api.db.db import anorm._  val stat = db.withconnection(implicit c => sql("select name, email user id=?").filledstatement) 

now how use it? event doing right? totally ignorant of anorm api , went through source code without gaining insight.

code examples more welcome.

a example on anorm usage given in respective tutorial. contains examples pass dynamic parameters queries. should start writing query , replace declare placeholders {someplaceholder} in query string. can later assign values using .on() method this:

sql(   """     select * country c      join countrylanguage l on l.countrycode = c.code      c.code = {countrycode};   """ ).on("countrycode" -> "fra") 

or in case:

import play.api.db.db import anorm._  val stat = db.withconnection(implicit c =>   sql("select name, email user id={id}").on("id" -> 42) ) 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -