User Tools

Site Tools


lua:db:escape

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lua:db:escape [2016/02/08 05:14] – created vodurlua:db:escape [2016/02/08 05:35] (current) vodur
Line 1: Line 1:
 db.escape( text ) db.escape( text )
  
-Returns the text with necessary escaping for use in sqlite3 statement.+Returns the text with necessary escaping for use as a parameter in sqlite3 statement.
  
-Implemented by passing the text to [[https://www.sqlite.org/c3ref/mprintf.html|sqlite3_mprintf]] using '%q'.+Implemented by passing the text to [[https://www.sqlite.org/c3ref/mprintf.html|sqlite3_mprintf]] using "%q" as the format string and text as the argument. 
 + 
 +<code lua> 
 +local str1=db.escape("db.escape will not change this string"
 +local str2=db.escape("db.escape won't not change this string"
 +say(str1) 
 +say(str2) 
 +db.exec( ([[INSERT INTO some_table VALUES( '%s', '%s' )]]):format( str1, str2) ) 
 +</code> 
 + 
 +<code> 
 +You say 'db.escape will not change this string' 
 +You say 'db.escape won''t not change this string' 
 +</code>
  
lua/db/escape.1454908480.txt.gz · Last modified: 2016/02/08 05:14 by vodur