Page 1 of 1

php and sqlite

Posted: Thu Jul 09, 2009 6:45 am
by danielrs1
I have created a sqlite table using this SQL command:

Code: Select all

CREATE TABLE board (id INTEGER PRIMARY KEY,message TEXT, username TEXT, timestamp INTEGER);
and I'm inserting rows using this PHP code:

Code: Select all

sqlite_exec($db,"INSERT INTO board (username,message,timestamp) VALUES ('".$currentUser."','".sqlite_escape_string($GLOBALS['eyeCometPOC_Textbox']->text)."','".time()."');")
How can I get the auto-generated id?

Re: php and sqlite

Posted: Thu Jul 09, 2009 8:54 am
by jackpf
Apparently you can execute a query with "SELECT last_insert_rowid()".

I did find this on google btw...

Re: php and sqlite

Posted: Thu Jul 09, 2009 11:18 am
by danielrs1
That's what I needed. Thanks :bow:

Re: php and sqlite

Posted: Thu Jul 09, 2009 11:30 am
by jackpf
Lol np :)

Re: php and sqlite

Posted: Thu Jul 09, 2009 1:09 pm
by McInfo
PHP Manual: sqlite_last_insert_rowid

Edit: This post was recovered from search engine cache.

Re: php and sqlite

Posted: Thu Jul 09, 2009 2:26 pm
by danielrs1
That's even better :D

I really love this Forum :drunk: