From: Dan Scott Date: Tue, 8 Mar 2005 18:12:22 +0000 (+0000) Subject: Add simple tests for insert through PDO::prepare/PDOStatement::execute. X-Git-Tag: RELEASE_0_3~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83dfcbf3f611001c6b21115bbe49ad57e3ea538e;p=php Add simple tests for insert through PDO::prepare/PDOStatement::execute. Tests both question mark placeholders and named parameters. --- diff --git a/ext/pdo/tests/pdo_021.inc b/ext/pdo/tests/pdo_021.inc new file mode 100755 index 0000000000..48489f5b38 --- /dev/null +++ b/ext/pdo/tests/pdo_021.inc @@ -0,0 +1,42 @@ +exec($SQL['create1']); + +// Insert using question mark placeholders +$stmt = $DB->prepare($SQL['insert1']); +foreach ($data as $row) { + $stmt->execute($row); +} + +$select = $DB->query($SQL['select']); +$num = $select->fetchSingle(); +echo 'There are ' . $num . " rows in the table.\n"; + +// Insert using named parameters +$stmt2 = $DB->prepare($SQL['insert2']); +foreach ($data as $row) { + $stmt2->execute(array(':first'=>($row[0] + 5), ':second'=>$row[1], + ':third'=>$row[2])); +} + +$select = $DB->query($SQL['select']); +$num = $select->fetchSingle(); +echo 'There are ' . $num . " rows in the table.\n"; + +?> diff --git a/ext/pdo_odbc/tests/pdo_021.phpt b/ext/pdo_odbc/tests/pdo_021.phpt new file mode 100755 index 0000000000..08a263125f --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_021.phpt @@ -0,0 +1,20 @@ +--TEST-- +PDO_ODBC: PDOStatement::execute with parameter markers. +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECT-- +There are 6 rows in the table. +There are 12 rows in the table. +===DONE===