Hi Marcin, Thank you very much! The update statement works now!
There is a question about the insert statement, how can i use the prepareStatement ? ### "INSERT INTO blogs click_counts=100 WHERE id=1" ### I'm not familiar with it, Thanks very much! :) Cheers, Neil On Dec 18, 11:13 pm, Marcin Jurczuk <mjurc...@gmail.com> wrote: > 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" <anim...@gmail.com> 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 lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.