Skip to content

Commit 777aa91

Browse files
committed
Fetch pdo stmt after zpp
1 parent 9ee16a3 commit 777aa91

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ PHP_METHOD(PDOStatement, execute)
341341
{
342342
zval *input_params = NULL;
343343
int ret = 1;
344-
PHP_STMT_GET_OBJ;
345344

346345
ZEND_PARSE_PARAMETERS_START(0, 1)
347346
Z_PARAM_OPTIONAL
348347
Z_PARAM_ARRAY_OR_NULL(input_params)
349348
ZEND_PARSE_PARAMETERS_END();
350349

350+
PHP_STMT_GET_OBJ;
351351
PDO_STMT_CLEAR_ERR();
352352

353353
if (input_params) {
@@ -1163,7 +1163,6 @@ PHP_METHOD(PDOStatement, fetch)
11631163
zend_long how = PDO_FETCH_USE_DEFAULT;
11641164
zend_long ori = PDO_FETCH_ORI_NEXT;
11651165
zend_long off = 0;
1166-
PHP_STMT_GET_OBJ;
11671166

11681167
ZEND_PARSE_PARAMETERS_START(0, 3)
11691168
Z_PARAM_OPTIONAL
@@ -1172,6 +1171,7 @@ PHP_METHOD(PDOStatement, fetch)
11721171
Z_PARAM_LONG(off)
11731172
ZEND_PARSE_PARAMETERS_END();
11741173

1174+
PHP_STMT_GET_OBJ;
11751175
PDO_STMT_CLEAR_ERR();
11761176

11771177
if (!pdo_stmt_verify_mode(stmt, how, 0)) {
@@ -1196,14 +1196,13 @@ PHP_METHOD(PDOStatement, fetchObject)
11961196
zval old_ctor_args, *ctor_args = NULL;
11971197
int error = 0, old_arg_count;
11981198

1199-
PHP_STMT_GET_OBJ;
1200-
12011199
ZEND_PARSE_PARAMETERS_START(0, 2)
12021200
Z_PARAM_OPTIONAL
12031201
Z_PARAM_STR_EX(class_name, 1, 0)
12041202
Z_PARAM_ARRAY(ctor_args)
12051203
ZEND_PARSE_PARAMETERS_END();
12061204

1205+
PHP_STMT_GET_OBJ;
12071206
PDO_STMT_CLEAR_ERR();
12081207

12091208
if (!pdo_stmt_verify_mode(stmt, how, 0)) {
@@ -1255,13 +1254,13 @@ PHP_METHOD(PDOStatement, fetchObject)
12551254
PHP_METHOD(PDOStatement, fetchColumn)
12561255
{
12571256
zend_long col_n = 0;
1258-
PHP_STMT_GET_OBJ;
12591257

12601258
ZEND_PARSE_PARAMETERS_START(0, 1)
12611259
Z_PARAM_OPTIONAL
12621260
Z_PARAM_LONG(col_n)
12631261
ZEND_PARSE_PARAMETERS_END();
12641262

1263+
PHP_STMT_GET_OBJ;
12651264
PDO_STMT_CLEAR_ERR();
12661265

12671266
if (!do_fetch_common(stmt, PDO_FETCH_ORI_NEXT, 0, TRUE)) {
@@ -1282,7 +1281,6 @@ PHP_METHOD(PDOStatement, fetchAll)
12821281
zend_class_entry *old_ce;
12831282
zval old_ctor_args, *ctor_args = NULL;
12841283
int error = 0, flags, old_arg_count;
1285-
PHP_STMT_GET_OBJ;
12861284

12871285
ZEND_PARSE_PARAMETERS_START(0, 3)
12881286
Z_PARAM_OPTIONAL
@@ -1291,6 +1289,7 @@ PHP_METHOD(PDOStatement, fetchAll)
12911289
Z_PARAM_ZVAL(ctor_args)
12921290
ZEND_PARSE_PARAMETERS_END();
12931291

1292+
PHP_STMT_GET_OBJ;
12941293
if (!pdo_stmt_verify_mode(stmt, how, 1)) {
12951294
RETURN_FALSE;
12961295
}
@@ -1484,7 +1483,6 @@ PHP_METHOD(PDOStatement, bindValue)
14841483
struct pdo_bound_param_data param;
14851484
zend_long param_type = PDO_PARAM_STR;
14861485
zval *parameter;
1487-
PHP_STMT_GET_OBJ;
14881486

14891487
memset(&param, 0, sizeof(param));
14901488
param.paramno = -1;
@@ -1497,6 +1495,7 @@ PHP_METHOD(PDOStatement, bindValue)
14971495
}
14981496
}
14991497

1498+
PHP_STMT_GET_OBJ;
15001499
param.param_type = (int) param_type;
15011500

15021501
if (param.paramno > 0) {
@@ -1537,21 +1536,19 @@ PHP_METHOD(PDOStatement, bindColumn)
15371536
/* {{{ Returns the number of rows in a result set, or the number of rows affected by the last execute(). It is not always meaningful. */
15381537
PHP_METHOD(PDOStatement, rowCount)
15391538
{
1540-
PHP_STMT_GET_OBJ;
1541-
15421539
ZEND_PARSE_PARAMETERS_NONE();
15431540

1541+
PHP_STMT_GET_OBJ;
15441542
RETURN_LONG(stmt->row_count);
15451543
}
15461544
/* }}} */
15471545

15481546
/* {{{ Fetch the error code associated with the last operation on the statement handle */
15491547
PHP_METHOD(PDOStatement, errorCode)
15501548
{
1551-
PHP_STMT_GET_OBJ;
1552-
15531549
ZEND_PARSE_PARAMETERS_NONE();
15541550

1551+
PHP_STMT_GET_OBJ;
15551552
if (stmt->error_code[0] == '\0') {
15561553
RETURN_NULL();
15571554
}
@@ -1567,10 +1564,9 @@ PHP_METHOD(PDOStatement, errorInfo)
15671564
int error_count_diff = 0;
15681565
int error_expected_count = 3;
15691566

1570-
PHP_STMT_GET_OBJ;
1571-
15721567
ZEND_PARSE_PARAMETERS_NONE();
15731568

1569+
PHP_STMT_GET_OBJ;
15741570
array_init(return_value);
15751571
add_next_index_string(return_value, stmt->error_code);
15761572

@@ -1596,13 +1592,13 @@ PHP_METHOD(PDOStatement, setAttribute)
15961592
{
15971593
zend_long attr;
15981594
zval *value = NULL;
1599-
PHP_STMT_GET_OBJ;
16001595

16011596
ZEND_PARSE_PARAMETERS_START(2, 2)
16021597
Z_PARAM_LONG(attr)
16031598
Z_PARAM_ZVAL_EX(value, 1, 0)
16041599
ZEND_PARSE_PARAMETERS_END();
16051600

1601+
PHP_STMT_GET_OBJ;
16061602
if (!stmt->methods->set_attribute) {
16071603
goto fail;
16081604
}
@@ -1637,12 +1633,12 @@ static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_long
16371633
PHP_METHOD(PDOStatement, getAttribute)
16381634
{
16391635
zend_long attr;
1640-
PHP_STMT_GET_OBJ;
16411636

16421637
ZEND_PARSE_PARAMETERS_START(1, 1)
16431638
Z_PARAM_LONG(attr)
16441639
ZEND_PARSE_PARAMETERS_END();
16451640

1641+
PHP_STMT_GET_OBJ;
16461642
if (!stmt->methods->get_attribute) {
16471643
if (!generic_stmt_attr_get(stmt, return_value, attr)) {
16481644
pdo_raise_impl_error(stmt->dbh, stmt, "IM001",
@@ -1676,10 +1672,9 @@ PHP_METHOD(PDOStatement, getAttribute)
16761672
/* {{{ Returns the number of columns in the result set */
16771673
PHP_METHOD(PDOStatement, columnCount)
16781674
{
1679-
PHP_STMT_GET_OBJ;
1680-
16811675
ZEND_PARSE_PARAMETERS_NONE();
16821676

1677+
PHP_STMT_GET_OBJ;
16831678
RETURN_LONG(stmt->column_count);
16841679
}
16851680
/* }}} */
@@ -1689,12 +1684,12 @@ PHP_METHOD(PDOStatement, getColumnMeta)
16891684
{
16901685
zend_long colno;
16911686
struct pdo_column_data *col;
1692-
PHP_STMT_GET_OBJ;
16931687

16941688
ZEND_PARSE_PARAMETERS_START(1, 1)
16951689
Z_PARAM_LONG(colno)
16961690
ZEND_PARSE_PARAMETERS_END();
16971691

1692+
PHP_STMT_GET_OBJ;
16981693
if(colno < 0) {
16991694
pdo_raise_impl_error(stmt->dbh, stmt, "42P10", "column number must be non-negative");
17001695
RETURN_FALSE;
@@ -1876,12 +1871,12 @@ PHP_METHOD(PDOStatement, setFetchMode)
18761871
zend_long fetch_mode;
18771872
zval *args = NULL;
18781873
uint32_t num_args = 0;
1879-
PHP_STMT_GET_OBJ;
18801874

18811875
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l*", &fetch_mode, &args, &num_args) == FAILURE) {
18821876
RETURN_THROWS();
18831877
}
18841878

1879+
PHP_STMT_GET_OBJ;
18851880
RETVAL_BOOL(pdo_stmt_setup_fetch_mode(stmt, fetch_mode, args, num_args) == SUCCESS);
18861881
}
18871882
/* }}} */
@@ -1918,10 +1913,9 @@ static int pdo_stmt_do_next_rowset(pdo_stmt_t *stmt)
19181913

19191914
PHP_METHOD(PDOStatement, nextRowset)
19201915
{
1921-
PHP_STMT_GET_OBJ;
1922-
19231916
ZEND_PARSE_PARAMETERS_NONE();
19241917

1918+
PHP_STMT_GET_OBJ;
19251919
if (!stmt->methods->next_rowset) {
19261920
pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets");
19271921
RETURN_FALSE;
@@ -1941,10 +1935,9 @@ PHP_METHOD(PDOStatement, nextRowset)
19411935
/* {{{ Closes the cursor, leaving the statement ready for re-execution. */
19421936
PHP_METHOD(PDOStatement, closeCursor)
19431937
{
1944-
PHP_STMT_GET_OBJ;
1945-
19461938
ZEND_PARSE_PARAMETERS_NONE();
19471939

1940+
PHP_STMT_GET_OBJ;
19481941
if (!stmt->methods->cursor_closer) {
19491942
/* emulate it by fetching and discarding rows */
19501943
do {
@@ -1981,10 +1974,10 @@ PHP_METHOD(PDOStatement, debugDumpParams)
19811974

19821975
php_stream *out = php_stream_open_wrapper("php://output", "w", 0, NULL);
19831976
struct pdo_bound_param_data *param;
1984-
PHP_STMT_GET_OBJ;
19851977

19861978
ZEND_PARSE_PARAMETERS_NONE();
19871979

1980+
PHP_STMT_GET_OBJ;
19881981
if (out == NULL) {
19891982
RETURN_FALSE;
19901983
}

0 commit comments

Comments
 (0)