php and sqlite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danielrs1
Forum Commoner
Posts: 29
Joined: Wed Jun 24, 2009 5:30 pm

php and sqlite

Post 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?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: php and sqlite

Post by jackpf »

Apparently you can execute a query with "SELECT last_insert_rowid()".

I did find this on google btw...
danielrs1
Forum Commoner
Posts: 29
Joined: Wed Jun 24, 2009 5:30 pm

Re: php and sqlite

Post by danielrs1 »

That's what I needed. Thanks :bow:
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: php and sqlite

Post by jackpf »

Lol np :)
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: php and sqlite

Post by McInfo »

PHP Manual: sqlite_last_insert_rowid

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 2:06 pm, edited 1 time in total.
danielrs1
Forum Commoner
Posts: 29
Joined: Wed Jun 24, 2009 5:30 pm

Re: php and sqlite

Post by danielrs1 »

That's even better :D

I really love this Forum :drunk:
Post Reply