php-src/ext/pdo/pdo.php
Peter Kokot 02294f0c84 Make PHP development tools files and scripts executable
This patch makes several scripts and PHP development tools files
executable and adds more proper shebangs to the PHP scripts.

The `#!/usr/bin/env php` shebang provides running the script via
`./script.php` and uses env to find PHP script location on the system.
At the same time it still provides running the script with a user
defined PHP location using `php script.php`.
2018-08-29 20:58:17 +02:00

64 lines
1.2 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
dl('pdo.so');
dl('pdo_sqlite.so');
//$x = new PDO("oci:dbname=hostname", 'php', 'php');
$x = new PDO("sqlite::memory:");
$x->query("create table test(name string, value string)");
debug_zval_dump($x);
$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;
}
}
$stmt = null;
echo "DEFAULT:\n";
foreach ($x->query("select NAME, VALUE from test") as $row) {
print_r($row);
}
echo "OBJ:\n";
class Foo {
public $NAME = "Don't change me";
}
$foo = new foo;
foreach ($x->query("select NAME, VALUE from test", PDO_FETCH_COLUMN, 1) as $row) {
debug_zval_dump($row);
}
echo "Done\n";
exit;
$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";
echo "All done\n";
?>