GSAK (Geocaching Swiss Army Knife)
Contents - Index

SqlQuote (function)

SqlQuote(sData) : string

The is mainly to help Sqlite users cope with the apostrophe inside data strings when building sql commands. Sqlite denotes string data by surrounding it in single quotes. If your data has the possibility of having single quotes inside it, you must escape it (replace each single quote with two of them) otherwise you will get a sql syntax error. I would advise using this function when dealing with string data in sqlite.

For example, if you wanted to get a list of all caches codes that had been placed by the current cache placer your current sql would need to have been coded something like:

$by = Replace('"',"''",$d_PlacedBy)
$data = sqlite("sql","select code from caches where PlacedBy = '$by'")

This can now be coded as:

$data = sqlite("sql","select code from caches where PlacedBy = " + SqlQuote($d_PlacedBy))

Alpha List         Category List
Copyright 2004-2014 CWE Computer Services  
Privacy Policy Contact