简体   繁体   中英

Quoting in MonetDB

I have some PHP code that I'm trying to port from MySQL to MonetDB. The code uses ODBC, so in theory it should just be a case of changing the driver.

Here's an example of the SQL being generated by PHP and sent to the database:

SELECT mycolumn FROM foo WHERE bar="123";

Unfortunately MonetDB uses a different quoting convention to MySQL: column names need to be wrapped in double quotes, values in single quotes. So it would expect:

SELECT "mycolumn" FROM foo WHERE bar='123';

Rather than going through thousands of lines of PHP code fixing all this, is there any easy way to solve the problem? Can ODBC magically fix the quoting, or perhaps MonetDB has a config option to permit it?

There are no magical fixes nor flags for this issue, just either hard work or dirty hacks. Please note that column (and table) names only need to be quoted if they contain reserved character or consist of reserved words. Hence, changing string quotes might be enough. The proper way of generating these queries on ODBC would be prepared statements, where quotes are indeed added automatically. However, I am not sure what the MonetDB ODBC driver would do in this case when used from PHP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM