diff options
Diffstat (limited to 'ext/pdo/pdo.php')
-rwxr-xr-x | ext/pdo/pdo.php | 35 |
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"; + +?> |