}
/* update the column index on named bound parameters */
- if (stmt->dbh->placeholders_can_be_strings && stmt->bound_params) {
+ if (stmt->bound_params) {
struct pdo_bound_param_data *param;
if (SUCCESS == zend_hash_find(stmt->bound_params, stmt->columns[col].name,
¶m.name, &str_length, &num_index, 0, NULL)) {
param.namelen = str_length;
param.paramno = -1;
-
- if (!stmt->dbh->placeholders_can_be_strings) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support named placeholders");
- RETURN_FALSE;
- }
} else {
/* we're okay to be zero based here */
if (num_index < 0) {
}
}
- if (stmt->dbh->emulate_prepare) {
+ if (!stmt->dbh->supports_placeholders) {
int error_pos;
/* handle the emulated parameter binding,
* stmt->active_query_string holds the query with binds expanded and
param.paramno = -1;
param.param_type = PDO_PARAM_STR;
- if (stmt->dbh->placeholders_can_be_strings || !is_param) {
- if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
- ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!",
- ¶m.name, &name_strlen, ¶m.parameter, ¶m.param_type,
- ¶m.max_value_len,
- ¶m.driver_params)) {
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|llz!", ¶m.paramno,
+ if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
+ ZEND_NUM_ARGS() TSRMLS_CC, "sz|llz!",
+ ¶m.name, &name_strlen, ¶m.parameter, ¶m.param_type,
+ ¶m.max_value_len,
+ ¶m.driver_params)) {
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|llz!", ¶m.paramno,
¶m.parameter, ¶m.param_type, ¶m.max_value_len, ¶m.driver_params)) {
- return 0;
- }
- }
+ return 0;
+ }
+ } else {
/* since we're hashing this, we need the null byte too */
param.namelen = name_strlen + 1;
- } else if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|llz!", ¶m.paramno,
- ¶m.parameter, ¶m.param_type, ¶m.max_value_len, ¶m.driver_params)) {
- return 0;
}
if (param.paramno > 0) {
static PHP_METHOD(PDOStatement, bindParam)
{
pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- if (!stmt->dbh->supports_placeholders) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support placeholders");
- RETURN_FALSE;
- }
-
RETURN_BOOL(register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, stmt, TRUE));
-
}
/* }}} */
if(strcmp(Z_STRVAL_P(member), "queryString") == 0) {
MAKE_STD_ZVAL(return_value);
ZVAL_STRINGL(return_value, stmt->query_string, stmt->query_stringlen, 1);
- }
- else {
+ } else {
MAKE_STD_ZVAL(return_value);
ZVAL_NULL(return_value);
}
/* }}} */
+enum pdo_placeholder_support {
+ PDO_PLACEHOLDER_NONE=0,
+ PDO_PLACEHOLDER_NAMED=1,
+ PDO_PLACEHOLDER_POSITIONAL=2
+};
+
/* represents a connection to a database */
struct _pdo_dbh_t {
/* driver specific methods */
unsigned alloc_own_columns:1;
/* if true, the driver supports placeholders and can implement
- * bindParam() for its prepared statements */
- unsigned supports_placeholders:1;
-
- /* if true, the driver allows named placeholders */
- unsigned placeholders_can_be_strings:1;
+ * bindParam() for its prepared statements, if false, PDO should
+ * emulate prepare and bind on its behalf */
+ unsigned supports_placeholders:2;
/* if true, commit or rollBack is allowed to be called */
unsigned in_txn:1;
- /* if true, PDO should emulate prepare() and bound input parameters for
- * the driver */
- unsigned emulate_prepare:1;
-
/* max length a single character can become after correct quoting */
unsigned max_escaped_char_length:3;
/* the sum of the number of bits here and the bit fields preceeding should
* equal 32 */
- unsigned _reserved_flags:21;
+ unsigned _reserved_flags:22;
/* data source string used to open this handle */
const char *data_source;