Forum OpenACS Q&A: Re: sql query problem

Collapse
3: Re: sql query problem (response to 1)
Posted by Robert Locke on
Hi Char,

The query fails because it doesn't have single quotes around the string, like this: 'AXT1113'

However, with OpenACS's cool database API, you need not worry about that.  Just use bind variables like this:

SELECT book.issue FROM book WHERE book.issue = :issue
SELECT text.textid FROM text WHERE text.textid = :textID

OACS will take care of properly quoting the $issue and $textID variables, including escaping embedded quotes.  This is also more secure than embedding variables directly in your query string.

Check out:
    https://openacs.org/doc/openacs-4-6-3/db-api.html
    https://openacs.org/doc/openacs-4-6-3/db-api-detailed.html

Good luck...