mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
add support for pdo-pgsql in phpng refactoring
This commit is contained in:
parent
f2324a3e0e
commit
b7f6bc5103
3 changed files with 80 additions and 68 deletions
|
@ -255,16 +255,17 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
case PDO_PARAM_EVT_NORMALIZE:
|
||||
/* decode name from $1, $2 into 0, 1 etc. */
|
||||
if (param->name) {
|
||||
if (param->name[0] == '$') {
|
||||
param->paramno = atoi(param->name + 1);
|
||||
if (param->name->val[0] == '$') {
|
||||
param->paramno = atoi(param->name->val + 1);
|
||||
} else {
|
||||
/* resolve parameter name to rewritten name */
|
||||
char *nameptr;
|
||||
if (stmt->bound_param_map && SUCCESS == zend_hash_find(stmt->bound_param_map,
|
||||
param->name, param->namelen + 1, (void**)&nameptr)) {
|
||||
param->paramno = atoi(nameptr + 1) - 1;
|
||||
zval *namevar;
|
||||
|
||||
if (stmt->bound_param_map && (namevar = zend_hash_find(stmt->bound_param_map,
|
||||
param->name)) != NULL) {
|
||||
param->paramno = atoi(Z_PTR_P(namevar) + 1) - 1;
|
||||
} else {
|
||||
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name TSRMLS_CC);
|
||||
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val TSRMLS_CC);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +304,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
}
|
||||
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB &&
|
||||
Z_TYPE_P(param->parameter) == IS_RESOURCE) {
|
||||
Z_TYPE(param->parameter) == IS_RESOURCE) {
|
||||
php_stream *stm;
|
||||
php_stream_from_zval_no_verify(stm, ¶m->parameter);
|
||||
if (stm) {
|
||||
|
@ -325,12 +326,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
int len;
|
||||
|
||||
SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
Z_TYPE_P(param->parameter) = IS_STRING;
|
||||
Z_TYPE_INFO(param->parameter) = IS_STRING;
|
||||
|
||||
if ((len = php_stream_copy_to_mem(stm, &Z_STRVAL_P(param->parameter), PHP_STREAM_COPY_ALL, 0)) > 0) {
|
||||
Z_STRLEN_P(param->parameter) = len;
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(param->parameter);
|
||||
if ((Z_STR(param->parameter) = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0)) == NULL) {
|
||||
ZVAL_EMPTY_STRING(¶m->parameter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -341,18 +340,18 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
}
|
||||
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL ||
|
||||
Z_TYPE_P(param->parameter) == IS_NULL) {
|
||||
Z_TYPE(param->parameter) == IS_NULL) {
|
||||
S->param_values[param->paramno] = NULL;
|
||||
S->param_lengths[param->paramno] = 0;
|
||||
} else if (Z_TYPE_P(param->parameter) == IS_BOOL) {
|
||||
S->param_values[param->paramno] = Z_BVAL_P(param->parameter) ? "t" : "f";
|
||||
} else if (Z_TYPE(param->parameter) == IS_FALSE || Z_TYPE(param->parameter) == IS_TRUE) {
|
||||
S->param_values[param->paramno] = Z_TYPE(param->parameter) == IS_TRUE ? "t" : "f";
|
||||
S->param_lengths[param->paramno] = 1;
|
||||
S->param_formats[param->paramno] = 0;
|
||||
} else {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
convert_to_string(param->parameter);
|
||||
S->param_values[param->paramno] = Z_STRVAL_P(param->parameter);
|
||||
S->param_lengths[param->paramno] = Z_STRLEN_P(param->parameter);
|
||||
convert_to_string_ex(¶m->parameter);
|
||||
S->param_values[param->paramno] = Z_STRVAL(param->parameter);
|
||||
S->param_lengths[param->paramno] = Z_STRLEN(param->parameter);
|
||||
S->param_formats[param->paramno] = 0;
|
||||
}
|
||||
|
||||
|
@ -371,7 +370,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
|
||||
SEPARATE_ZVAL(¶m->parameter);
|
||||
param->param_type = PDO_PARAM_STR;
|
||||
ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1);
|
||||
ZVAL_STRINGL(¶m->parameter, Z_TYPE(param->parameter) == IS_TRUE ? "t" : "f", 1);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -450,11 +449,9 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
|
|||
case OIDOID:
|
||||
/* did the user bind the column as a LOB ? */
|
||||
if (stmt->bound_columns && (
|
||||
SUCCESS == zend_hash_index_find(stmt->bound_columns,
|
||||
colno, (void**)¶m) ||
|
||||
SUCCESS == zend_hash_find(stmt->bound_columns,
|
||||
cols[colno].name, cols[colno].namelen,
|
||||
(void**)¶m))) {
|
||||
(param = zend_hash_index_find(stmt->bound_columns, colno)) != NULL ||
|
||||
(param = zend_hash_str_find(stmt->bound_columns, cols[colno].name, cols[colno].namelen)) != NULL)) {
|
||||
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) {
|
||||
cols[colno].param_type = PDO_PARAM_LOB;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue