summaryrefslogtreecommitdiff
path: root/ext/pdo_pgsql
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2006-04-09 08:17:50 +0000
committerWez Furlong <wez@php.net>2006-04-09 08:17:50 +0000
commitf83cfb77bfc3738b239a9987491ecb6e6b003231 (patch)
tree32f9271801f455dc4725bd9251384ab1e4437e12 /ext/pdo_pgsql
parentb9f85f37cc867b9afe1a6c7114e165a0d44e62f9 (diff)
downloadphp-git-f83cfb77bfc3738b239a9987491ecb6e6b003231.tar.gz
be aware of PDO_ATTR_EMULATE_PREPARES
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index 8e90513ae4..7b1561506a 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -218,6 +218,7 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
int ret;
char *nsql = NULL;
int nsql_len = 0;
+ int emulate = 0;
#endif
S->H = H;
@@ -233,9 +234,18 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len,
}
#if HAVE_PQPREPARE
- if ((!driver_options || pdo_attr_lval(driver_options,
- PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, 0 TSRMLS_CC) == 0)
- && PQprotocolVersion(H->server) > 2) {
+
+ if (driver_options) {
+ if (pdo_attr_lval(driver_options,
+ PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, 0 TSRMLS_CC) == 1) {
+ emulate = 1;
+ } else if (pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES,
+ 0 TSRMLS_CC) == 1) {
+ emulate = 1;
+ }
+ }
+
+ if (!emulate && PQprotocolVersion(H->server) > 2) {
stmt->supports_placeholders = PDO_PLACEHOLDER_NAMED;
stmt->named_rewrite_template = "$%d";
ret = pdo_parse_params(stmt, (char*)sql, sql_len, &nsql, &nsql_len TSRMLS_CC);