Re: [sqlite] [PHP5-FPM/Sqlite3] PDO can create file but no more

2010-07-28 Thread Gilles Ganault
On Tue, 27 Jul 2010 22:56:23 -0700, Roger Binns
 wrote:
>You can if you quote it.  Note use double quotes to quote table & column
>names, single quotes for strings.  You can also quote names using square
>brackets - eg [table name].

Thanks Roger for the tip.

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


Re: [sqlite] [PHP5-FPM/Sqlite3] PDO can create file but no more

2010-07-28 Thread Simon Slavin

On 28 Jul 2010, at 6:56am, Roger Binns wrote:

> This works:
> 
>  create table ""("" "");

The obfuscated SQLite contest closed three months ago.

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


Re: [sqlite] [PHP5-FPM/Sqlite3] PDO can create file but no more

2010-07-27 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 07/27/2010 05:48 AM, Gilles Ganault wrote:
> Found it: For newbies like me... "table" is a reserved name so cannot
> be used as a name to table:

You can if you quote it.  Note use double quotes to quote table & column
names, single quotes for strings.  You can also quote names using square
brackets - eg [table name].

  create table "table"(...)

Heck SQLite even lets you create tables and columns with zero length names.
 This works:

  create table ""("" "");

Obviously I wouldn't recommend doing that, nor using reserved names :-)

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxPxoEACgkQmOOfHg372QSzjQCggSYL4xSQVUG83Cfz7N1XFCnc
absAoKipjx0W6L6w4TIhXM9KWmhFRgn6
=u0Bs
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [PHP5-FPM/Sqlite3] PDO can create file but no more

2010-07-27 Thread Gilles Ganault
On Tue, 27 Jul 2010 14:40:11 +0200, Gilles Ganault
 wrote:
>I'm having a problem with this PHP5 script running under Nginx +
>PHP5-FPM and PDO-SQLite3

Found it: For newbies like me... "table" is a reserved name so cannot
be used as a name to table:


#BAD $dbh->exec("CREATE TABLE IF NOT EXISTS table (id INTEGER PRIMARY
KEY AUTOINCREMENT, name VARCHAR(255))"); 
#BAD $dbh->exec("INSERT INTO table (name) VALUES ('dummy')");

$dbh->exec("CREATE TABLE IF NOT EXISTS mytable (id INTEGER PRIMARY KEY
AUTOINCREMENT, name VARCHAR(255))"); 
$dbh->exec("INSERT INTO mytable (name) VALUES ('dummy')");


HTH,

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


[sqlite] [PHP5-FPM/Sqlite3] PDO can create file but no more

2010-07-27 Thread Gilles Ganault
Hello

I'm having a problem with this PHP5 script running under Nginx +
PHP5-FPM and PDO-SQLite3:
=
exec("CREATE TABLE IF NOT EXISTS table (id INTEGER PRIMARY
KEY AUTOINCREMENT, name VARCHAR(255))"); 
$dbh->exec("INSERT INTO table (name) VALUES ('dummy')");

$dbh = null;
  } catch(PDOException $e) { 
  echo $e->getMessage();
  }
?> 
=

The script successfully creates the database file... but it remains
empty, with no error message reported.

FWIW, Nginx spawns child processes (threads?) as www-data, PHP5-FPM
does the same, and the www directory is owned by www-data:

=
# ps aux | grep -i -e nginx -e php5 | grep -v grep

root   nginx: master process /usr/sbin/nginx
www-data   nginx: worker process

root   /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
=
# ll /var/www/nginx-default/

drwxr-xr-x  6 www-data www-data 4096 2010-07-27 14:24 ./
drwxr-xr-x  3 root root 4096 2010-07-27 13:00 ../

-rw-r--r--  1 www-data www-data0 2010-07-27 14:21 dummy.sqlite

-rw-r--r--  1 www-data www-data  565 2010-07-27 14:24
sqlite3_pdo_test.php
=

Thank you for any hint.

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