Hi,

I ran exactly the code you put below, but it only return:  bool(false)

<?php
try {
$dbh = new PDO('sqlite:db1.db');
$result=$dbh->query("drop table if exists tbl2");
$result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));");
var_dump($result);
}
catch(PDOException $e)
{
  print "Oops!\n";
  print 'Exception : '.$e->getMessage()."\n";
}
?>



----- Original Message ----
From: "Black, Michael (IS)" <michael.bla...@ngc.com>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Fri, 8 July, 2011 8:27:35 PM
Subject: Re: [sqlite] Insert not working for sqlite3

I downloaded 5.3.6 from here -- I used the Thread Safe version Installer.

http://windows.php.net/download/



And you're script ran just fine and created this:

sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE tbl2 (one varchar(10),two varchar(10));
COMMIT;



I the modified your script to run a bit better as you will see "false" the 2nd 
time your script is run as the table already exists.

<?php
try {
$dbh = new PDO('sqlite:db1.db');
$result=$dbh->query("drop table if exists tbl2");
$result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));");
var_dump($result);
}
catch(PDOException $e)
{
  print "Oops!\n";
  print 'Exception : '.$e->getMessage()."\n";
}
?>



So now every time I run it we get this:

D:\php>php <db.php
object(PDOStatement)#3 (1) {
  ["queryString"]=>
  string(52) "create table tbl2 (one varchar(10),two varchar(10));"
}



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 James_21th [james_2...@yahoo.com]
Sent: Thursday, July 07, 2011 8:50 PM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Insert not working for sqlite3

Dear all,

Thank you for all your valuable suggestion, it's good idea to put the whole
script here, also good idea everytime to check the result, so I put the whole
script here:
The $result always return false, it don't allow me to create a simple table, the
table name surely not exist, I change tbl3, 4, 5, all not able to create. (that
could be the same reason why insert is not working, if not even able to create
table, let alone insert.)

<?php
$dbh = new PDO('sqlite:db1.db');
$result=$dbh->query("create table tbl2 (one varchar(10),two varchar(10));");
var_dump($result);
?>



----- Original Message ----
From: Stephan Beal <sgb...@googlemail.com>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Thu, 7 July, 2011 9:18:07 PM
Subject: Re: [sqlite] Insert not working for sqlite3

On Thu, Jul 7, 2011 at 2:17 PM, Simon Slavin <slav...@bigfraud.org> wrote:

> For each operation you should test the $result and check to see it's
> SQLITE_OK.
>

Or enable exceptions and you don't have to check for errors (because they
will cause an exception).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to