I'm having a fundamental problem using PDO in a very simple context.
Here's the entire script. It connects to a DB2 dbase called 'SAMPLE'.
There is a table within SAMPLE called TEST2 and TEST2 has two columns, my_name and my_notes. The script:
Code: Select all
<?php
// Get a PDO database handle object
$dbh = new PDO("odbc:SAMPLE");
// Insert two values into database table ( NOT WORKING! )
$sth = $dbh->prepare("INSERT INTO test2 (my_name, my_notes) VALUES(?, ?)");
$sth->execute(array("My Name", "A note..."));
// Select all values from database table, print to stdout
$sth = $dbh->prepare("SELECT * FROM test2");
try { $sth->execute(); }
catch (PDOException $e) { exit($e->getMessage()); }
// Print rows just fetched
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { print_r($row); }
?>Code: Select all
Array
(
[MY_NAME] => A note...
[MY_NOTES] => A note...
)