summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2014-11-13 14:23:25 +0800
committerXinchen Hui <laruence@php.net>2014-11-13 14:23:25 +0800
commit6771f5590c88c5550ccd43c9ac4c5c4448bf45ef (patch)
tree1eb3dc354ccddc4163fe81d4e1bbfd420027fd6d
parent241b1a78401771c78a8f6c76dbad43de6053c558 (diff)
downloadphp-git-6771f5590c88c5550ccd43c9ac4c5c4448bf45ef.tar.gz
Another fix for test fail
-rw-r--r--ext/pdo/pdo_stmt.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 705d08bacf..dbc98c6e5f 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2486,6 +2486,7 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl
pdo_stmt_t *stmt = row->stmt;
int colno = -1;
zval zobj;
+ zend_long lval;
ZVAL_NULL(rv);
if (stmt) {
@@ -2493,6 +2494,11 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl
if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) {
fetch_value(stmt, rv, Z_LVAL_P(member), NULL TSRMLS_CC);
}
+ } else if (Z_TYPE_P(member) == IS_STRING
+ && is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) {
+ if (lval >= 0 && lval < stmt->column_count) {
+ fetch_value(stmt, rv, lval, NULL TSRMLS_CC);
+ }
} else {
convert_to_string(member);
/* TODO: replace this with a hash of available column names to column
@@ -2541,19 +2547,24 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c
pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object);
pdo_stmt_t *stmt = row->stmt;
int colno = -1;
+ zend_long lval;
if (stmt) {
if (Z_TYPE_P(member) == IS_LONG) {
return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count;
+ } else if (Z_TYPE_P(member) == IS_STRING) {
+ if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) {
+ return lval >=0 && lval < stmt->column_count;
+ }
} else {
convert_to_string(member);
+ }
- /* TODO: replace this with a hash of available column names to column
- * numbers */
- for (colno = 0; colno < stmt->column_count; colno++) {
- if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
- return 1;
- }
+ /* TODO: replace this with a hash of available column names to column
+ * numbers */
+ for (colno = 0; colno < stmt->column_count; colno++) {
+ if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
+ return 1;
}
}
}