Skip to content

Commit

Permalink
be aware of PDO_ATTR_EMULATE_PREPARES
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed Apr 9, 2006
1 parent b9f85f3 commit f83cfb7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ext/pdo_pgsql/pgsql_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit f83cfb7

Please sign in to comment.