in reply to SQL quoting problem
I am using Sybase ASE 12.0 and DBD::Sybase to allow users to query a full-text server that joins with another database.
I put my queries into variables and escape any embedded quotes. This permits me to employ nested quotes in certain situations:
The $fts string must be enclosed in single quotes, and may contain literals, which need to be enclosed in double quotes:$query = "select col_a, col_b, col_c from tablea, tableb where tablea..pkey = tableb..fkey and tablea..column_x = '$fts'";
Note that the only time I actually need to escape the quotes are when a double quote is employed within a string variable.$fts = "(seedling \<or\> kernel \<or\> embryo) \<and\> \"viab*\" ";
The final form of the query passed to the Sybase server is:
select a,b,c from tablea, tableb
where tablea..pkey = tableb..fkey
and tablea..column_x = '(kernel <or> embryo) <and> "viab*"'
-----
"Computeri non cogitant, ergo non sunt"
|
---|