georg           Wed Jun 22 06:14:34 2005 EDT

  Added files:                 
    /php-src/ext/mysqli/tests   067.phpt 
  Log:
  added testcase for cursors (nested selects)
  
  

http://cvs.php.net/co.php/php-src/ext/mysqli/tests/067.phpt?r=1.1&p=1
Index: php-src/ext/mysqli/tests/067.phpt
+++ php-src/ext/mysqli/tests/067.phpt
--TEST--
function test: nested selects (cursors)
--SKIPIF--
<?php 
        require_once('skipif.inc'); 
        /* skip cursor test for versions < 50004 */
        if (mysqli_get_client_version() < 50009) {
                die("skip Client library doesn't support cursors");     
        }
?>
--FILE--
<?php

        function open_cursor($mysql, $query) {
                $stmt = $mysql->prepare($query);
                $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, 
MYSQLI_CURSOR_TYPE_READ_ONLY);
                return $stmt;
        }

        include "connect.inc";
        $a = array();
        
        /*** test mysqli_connect 127.0.0.1 ***/
        $mysql = new mysqli($host, $user, $passwd, "test");

        for ($i=0;$i < 3; $i++) {
                $mysql->query("DROP TABLE IF EXISTS cursor$i");
                $mysql->query("CREATE TABLE cursor$i (a int not null)");
                $mysql->query("INSERT INTO cursor$i VALUES 
(1),(2),(3),(4),(5),(6)");
                $stmt[$i] = open_cursor($mysql, "SELECT a FROM cursor$i");
                $stmt[$i]->execute();
                $stmt[$i]->bind_result($a[$i]);
        }

        
        $cnt = 0;
        while ($stmt[0]->fetch()) {
                $stmt[1]->fetch();
                $stmt[2]->fetch();
                $cnt += $a[0] + $a[1] + $a[2];
        }

        for ($i=0; $i < 3; $i++) {
                $stmt[$i]->close();
        }

        $mysql->close();
        var_dump($cnt);
?>
--EXPECT--
int(63)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to