summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo.php
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2004-05-17 15:41:51 +0000
committerWez Furlong <wez@php.net>2004-05-17 15:41:51 +0000
commit684be9cf36c48893d98f980eafc4fe08ac98dbfa (patch)
tree2a6f986315c5eb1663a5295ac53fc1322c5fe388 /ext/pdo/pdo.php
parent3a4f33e31ff77da46b24b2651fed259ca52104c6 (diff)
downloadphp-git-684be9cf36c48893d98f980eafc4fe08ac98dbfa.tar.gz
Hello PDO.
Still more to come. Give it a couple of days before starting to write drivers for the other databases; a few things might change, so I'd like to coordinate that, but in a couple of days.
Diffstat (limited to 'ext/pdo/pdo.php')
-rwxr-xr-xext/pdo/pdo.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/pdo/pdo.php b/ext/pdo/pdo.php
new file mode 100755
index 0000000000..78300d82b5
--- /dev/null
+++ b/ext/pdo/pdo.php
@@ -0,0 +1,35 @@
+<?php
+
+//$x = new PDO("oci:dbname=hostname", 'php', 'php');
+$x = new PDO("odbc:ram", 'php', 'php', array(PDO_ATTR_AUTOCOMMIT => 0));
+$stmt = $x->prepare("select NAME, VALUE from test where value like ?");
+
+$the_name = 'bar%';
+$stmt->execute(array($the_name)) or die("failed to execute!");
+$stmt->bindColumn('VALUE', $value);
+
+while ($row = $stmt->fetch()) {
+ echo "name=$row[NAME] value=$row[VALUE]\n";
+ echo "value is $value\n";
+ echo "\n";
+}
+
+echo "Let's try an update\n";
+
+$stmt = $x->prepare("INSERT INTO test (NAME, VALUE) VALUES (:name, :value)");
+
+$stmt->bindParam(":name", $the_name, PDO_PARAM_STR, 32);
+$stmt->bindParam(":value", $the_value, PDO_PARAM_STR, 32);
+
+for ($i = 0; $i < 4; $i++) {
+ $the_name = "foo" . rand();
+ $the_value = "bar" . rand();
+
+ if (!$stmt->execute()) {
+ break;
+ }
+}
+
+echo "All done\n";
+
+?>