Skip to content

Commit a034766

Browse files
committed
Fix queryString property handling
1 parent acdf697 commit a034766

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,9 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi
22622262
ZEND_ASSERT(stmt);
22632263

22642264
ZVAL_NULL(rv);
2265-
if (is_numeric_string(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0) == IS_LONG) {
2265+
if (zend_string_equals_literal(name, "queryString")) {
2266+
return zend_std_read_property(&stmt->std, name, type, cache_slot, rv);
2267+
} else if (is_numeric_string(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0) == IS_LONG) {
22662268
if (lval >= 0 && lval < stmt->column_count) {
22672269
fetch_value(stmt, rv, lval, NULL);
22682270
}
@@ -2275,9 +2277,6 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi
22752277
return rv;
22762278
}
22772279
}
2278-
if (zend_string_equals_literal(name, "queryString")) {
2279-
return zend_std_read_property(&stmt->std, name, type, cache_slot, rv);
2280-
}
22812280
}
22822281

22832282
return rv;
@@ -2306,6 +2305,10 @@ static zval *row_dim_read(zend_object *object, zval *member, int type, zval *rv)
23062305
return &EG(uninitialized_zval);
23072306
}
23082307

2308+
if (zend_string_equals_literal(Z_STR_P(member), "queryString")) {
2309+
return zend_std_read_property(&stmt->std, Z_STR_P(member), type, NULL, rv);
2310+
}
2311+
23092312
/* TODO: replace this with a hash of available column names to column
23102313
* numbers */
23112314
for (colno = 0; colno < stmt->column_count; colno++) {
@@ -2314,9 +2317,6 @@ static zval *row_dim_read(zend_object *object, zval *member, int type, zval *rv)
23142317
return rv;
23152318
}
23162319
}
2317-
if (zend_string_equals_literal(Z_STR_P(member), "queryString")) {
2318-
return zend_std_read_property(&stmt->std, Z_STR_P(member), type, NULL, rv);
2319-
}
23202320
}
23212321

23222322
return rv;

ext/pdo_sqlite/tests/bug44327_2.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object(PDOStatement)#%d (1) {
3232
string(23) "select 1 as queryString"
3333
array(2) {
3434
["queryString"]=>
35-
int(1)
35+
string(23) "select 1 as queryString"
3636
[0]=>
3737
int(1)
3838
}
@@ -45,6 +45,6 @@ object(PDOStatement)#%d (1) {
4545
string(23) "select 1 as queryString"
4646
object(PDORow)#%d (1) {
4747
["queryString"]=>
48-
int(1)
48+
string(23) "select 1 as queryString"
4949
}
50-
int(1)
50+
string(23) "select 1 as queryString"

0 commit comments

Comments
 (0)