reverse arguments of pq\Result::fetchCol()
authorMichael Wallner <mike@php.net>
Wed, 17 Sep 2014 07:17:13 +0000 (09:17 +0200)
committerMichael Wallner <mike@php.net>
Wed, 17 Sep 2014 07:17:13 +0000 (09:17 +0200)
src/php_pqres.c
tests/basic002.phpt
tests/encoding001.phpt
tests/unbuffered001.phpt

index cd3b2b740b375f85cd7d06a9ac7135baa5019a4e..eeda25899fbbff521836d2775c2ce4c3f43abd0b 100644 (file)
@@ -775,17 +775,17 @@ static zval **column_at(zval *row, int col TSRMLS_DC)
        return data;
 }
 
-ZEND_BEGIN_ARG_INFO_EX(ai_pqres_fetch_col, 0, 0, 2)
-       ZEND_ARG_INFO(0, col)
+ZEND_BEGIN_ARG_INFO_EX(ai_pqres_fetch_col, 0, 0, 1)
        ZEND_ARG_INFO(1, ref)
+       ZEND_ARG_INFO(0, col)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqres, fetchCol) {
        zend_error_handling zeh;
-       zval *zcol, *zref;
+       zval *zcol = NULL, *zref;
        STATUS rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
-       rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z", &zcol, &zref);
+       rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z/!", &zref, &zcol);
        zend_restore_error_handling(&zeh TSRMLS_CC);
 
        if (SUCCESS == rv) {
index 4a6fbd82708503faa8873b9af03728e85dc35986..2afb78503e1baba56fb2ffea863c818c653100c4 100644 (file)
@@ -13,7 +13,7 @@ $s = $c->prepare("test1", "SELECT \$1",array($t["text"]->oid));
 $r = $s->exec(array("fooo"));
 
 printf("%s\n", $r->errorMessage);
-$r->fetchCol(0, $val);
+$r->fetchCol($val);
 printf("%s\n", $val);
 ?>
 DONE
index b4067bcebde53ec7a42c4241d477e63d06631585..53bcef5f6222751c29073084658e8f634778cb7a 100644 (file)
@@ -11,7 +11,7 @@ $c = new pq\Connection(PQ_DSN);
 var_dump($c->encoding);
 $c->encoding = "utf8";
 var_dump($c->encoding);
-$c->exec("SELECT 'ßüpä…'")->fetchCol(0, $val);
+$c->exec("SELECT 'ßüpä…'")->fetchCol($val);
 var_dump($val);
 $tmp = 12345;
 $c->encoding = $tmp;
index b0df231c007a863b433051a0da45302709946684..4bc4d8575132e07fee8627fc12b0ca4cc2e40f9a 100644 (file)
@@ -16,7 +16,7 @@ var_dump($c->unbuffered);
 $c->execAsync("SELECT a from generate_series(1,10) a", function($res) {
        switch ($res->status) {
        case pq\Result::SINGLE_TUPLE:
-               $res->fetchCol("a", $val);
+               $res->fetchCol($val, "a");
                printf("%s\n", $val);
                break;
        case pq\Result::TUPLES_OK: