Hi,

You have few options:
- DB.runQuery("UPDATE blogs set click_counts=click_counts+1 WHERE
id=1")
- DBprepareStatement("UPDATE blogs set click_counts=click_counts+1
WHERE id=?",yourDBConnection) {
stmt =>
stmt.setLong(1,1)
stmt.executeUpdate()
}
Where first 1 in setLong is position in prepared statment where you
will put second value. Since You have only one ? it always will be
"1".

WARNING:
runQuery is vulnerable to SQL injection in many situations (mostly
where string is passed to query)


Marcin,

On 18 Gru, 15:45, "Neil.Lv" <[email protected]> wrote:
> Hi all,
>
>    How can i update and insert record into database via Raw sql in
> Lift?
>
>    I write some code but it failed, here is :
>
> ### In the model
>
>   def updateClickCountsById(id: Long) =
>     DB.runQuery("UPDATE blogs set click_counts=click_counts+1 WHERE
> id=1")
>
>   def insertRecord() =
>     DB.runQuery("INSERT INTO blogs click_counts=100 WHERE id=1")
>
> ###
>
>    This two method doesn't work, so how can i update and insert via
> raw SQL in the lift with Mapper?
>
>    Thanks for any suggestion !
>
> Cheers,
>   Neil

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to