Annotation of embedaddon/php/ext/pdo/tests/pdo_021.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: PDO Common: PDOStatement::execute with parameters
        !             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: if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
        !            18:        $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
        !            19: }
        !            20: 
        !            21: $db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))');
        !            22: 
        !            23: $select = $db->prepare('SELECT COUNT(id) FROM test');
        !            24: 
        !            25: $data = array(
        !            26:     array('10', 'Abc', 'zxy'),
        !            27:     array('20', 'Def', 'wvu'),
        !            28:     array('30', 'Ghi', 'tsr'),
        !            29:     array('40', 'Jkl', 'qpo'),
        !            30:     array('50', 'Mno', 'nml'),
        !            31:     array('60', 'Pqr', 'kji'),
        !            32: );
        !            33: 
        !            34: 
        !            35: // Insert using question mark placeholders
        !            36: $stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)");
        !            37: foreach ($data as $row) {
        !            38:     $stmt->execute($row);
        !            39: }
        !            40: $select->execute();
        !            41: $num = $select->fetchColumn();
        !            42: echo 'There are ' . $num . " rows in the table.\n";
        !            43: 
        !            44: // Insert using named parameters
        !            45: $stmt2 = $db->prepare("INSERT INTO test VALUES(:first, :second, :third)");
        !            46: foreach ($data as $row) {
        !            47:     $stmt2->execute(array(':first'=>($row[0] + 5), ':second'=>$row[1], 
        !            48:         ':third'=>$row[2]));
        !            49: }
        !            50: 
        !            51: $select->execute();
        !            52: $num = $select->fetchColumn();
        !            53: echo 'There are ' . $num . " rows in the table.\n";
        !            54: 
        !            55: 
        !            56: ?>
        !            57: --EXPECT--
        !            58: There are 6 rows in the table.
        !            59: There are 12 rows in the table.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>