If CREATE has no return why do I get a return?

To be clear I'm using PHP 5.3.6 and it most definitely gets a return

But I re-wrote this according to some PDO examples I found.  This is a more 
complete example.

You should be able to run this with a PHP command line -- forget the web 
interface until you get this working.

If the database can't be opened you'll get an exception.

If this doesn't work then open up the database with sqlite3 and .dump it.

try {
print "PDO test\n";
$dbh = new PDO('sqlite:db1.db');
$dbh->exec("drop table if exists tbl2");
$dbh->exec("create table tbl2 (one varchar(10),two varchar(10))");
$dbh->exec("insert into tbl2 values('test1a','test2a')");
$dbh->exec("insert into tbl2 values('test1b','test2b')");
$dbh->exec("insert into tbl2 values('test1c','test2c')");
$dbh->exec("insert into tbl2 values('test1d','test2d')");
$result=$dbh->query('select * from tbl2');
foreach($result as $row)
print "row=".$row['one'].",".$row['two']."\n";
print "Done\n";
catch(PDOException $e)
  print "Exception: ".$e->getMessage();

This displays this output

D:\SQLite>php -e <test2.php
PDO test

Plus...check your phpinfo() for the sqlite3 entries and show them to us.  The 
should look like this:

SQLite3 support => enabled
SQLite3 module version => 0.7-dev
SQLite Library => 3.7.4

Michael D. Black

Senior Scientist

NG Information Systems

Advanced Analytics Directorate

From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Stephan Beal [sgb...@googlemail.com]
Sent: Monday, July 11, 2011 6:10 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Insert not working for sqlite3

On Mon, Jul 11, 2011 at 2:41 AM, James_21th <james_2...@yahoo.com> wrote:

> $result=$dbh->query("create table tbl2 (one varchar(10),two
> varchar(10));");

A CREATE statement has no results. In PDO, only SELECT (and similar) return
a result, if i'm not mistaken.

----- stephan beal
sqlite-users mailing list
sqlite-users mailing list

Reply via email to