Annotation of embedaddon/php/ext/pdo/tests/pdo_019.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: PDO Common: fetch() and while()
! 3: --SKIPIF--
! 4: <?php # vim:ft=php
! 5: if (!extension_loaded('pdo')) die('skip');
! 6: $dir = getenv('REDIR_TEST_DIR');
! 7: if (false == $dir) die('skip no driver');
! 8: require_once $dir . 'pdo_test.inc';
! 9: PDOTest::skip();
! 10: ?>
! 11: --FILE--
! 12: <?php
! 13: if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
! 14: require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
! 15: $db = PDOTest::factory();
! 16:
! 17: $db->exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))');
! 18: $db->exec('INSERT INTO test VALUES(0, \'String0\')');
! 19: $db->exec('INSERT INTO test VALUES(1, \'String1\')');
! 20: $db->exec('INSERT INTO test VALUES(2, \'String2\')');
! 21: $db->exec('INSERT INTO test VALUES(3, \'String3\')');
! 22:
! 23:
! 24: var_dump($db->query('SELECT COUNT(*) FROM test')->fetchColumn());
! 25:
! 26: $stmt = $db->prepare('SELECT idx, txt FROM test ORDER by idx');
! 27:
! 28: $stmt->execute();
! 29: $cont = $stmt->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE);
! 30: var_dump($cont);
! 31:
! 32: echo "===WHILE===\n";
! 33:
! 34: $stmt->bindColumn('idx', $idx);
! 35: $stmt->bindColumn('txt', $txt);
! 36: $stmt->execute();
! 37:
! 38: while($stmt->fetch(PDO::FETCH_BOUND)) {
! 39: var_dump(array($idx=>$txt));
! 40: }
! 41:
! 42: ?>
! 43: --EXPECT--
! 44: string(1) "4"
! 45: array(4) {
! 46: [0]=>
! 47: string(7) "String0"
! 48: [1]=>
! 49: string(7) "String1"
! 50: [2]=>
! 51: string(7) "String2"
! 52: [3]=>
! 53: string(7) "String3"
! 54: }
! 55: ===WHILE===
! 56: array(1) {
! 57: [0]=>
! 58: string(7) "String0"
! 59: }
! 60: array(1) {
! 61: [1]=>
! 62: string(7) "String1"
! 63: }
! 64: array(1) {
! 65: [2]=>
! 66: string(7) "String2"
! 67: }
! 68: array(1) {
! 69: [3]=>
! 70: string(7) "String3"
! 71: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>