Annotation of embedaddon/php/ext/pdo/tests/pdo_034.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: PDO Common: PDO::FETCH_KEY_PAIR fetch mode test
! 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 (a varchar(100), b varchar(100), c varchar(100))");
! 18:
! 19: for ($i = 0; $i < 5; $i++) {
! 20: $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')");
! 21: }
! 22:
! 23: var_dump($db->query("SELECT a,b FROM test")->fetch(PDO::FETCH_KEY_PAIR));
! 24: var_dump($db->query("SELECT a,b FROM test")->fetchAll(PDO::FETCH_KEY_PAIR));
! 25: var_dump($db->query("SELECT * FROM test")->fetch(PDO::FETCH_KEY_PAIR));
! 26: var_dump($db->query("SELECT a,a FROM test")->fetchAll(PDO::FETCH_KEY_PAIR));
! 27:
! 28: ?>
! 29: --EXPECTF--
! 30: array(1) {
! 31: ["test0"]=>
! 32: string(1) "0"
! 33: }
! 34: array(5) {
! 35: ["test0"]=>
! 36: string(1) "0"
! 37: ["test1"]=>
! 38: string(1) "1"
! 39: ["test2"]=>
! 40: string(1) "2"
! 41: ["test3"]=>
! 42: string(1) "3"
! 43: ["test4"]=>
! 44: string(1) "4"
! 45: }
! 46:
! 47: Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain extactly 2 columns. in %spdo_034.php on line %d
! 48:
! 49: Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error%spdo_034.php on line %d
! 50: bool(false)
! 51: array(5) {
! 52: ["test0"]=>
! 53: string(5) "test0"
! 54: ["test1"]=>
! 55: string(5) "test1"
! 56: ["test2"]=>
! 57: string(5) "test2"
! 58: ["test3"]=>
! 59: string(5) "test3"
! 60: ["test4"]=>
! 61: string(5) "test4"
! 62: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>