note 51945 added to function.sqlite-last-insert-rowid
| From: | David at osu1 dot php dot net | Date: | Sat, 16 Apr 2005 02:50:40 +0000 |
| Subject: | note 51945 added to function.sqlite-last-insert-rowid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88078@lists.php.net to get a copy of this message | ||
I have noticed that this will still return an insert id even if a table has not been assigned a
primary key or has not been assigned a primary key correctly. If the table was not created correctly
sqlite_last_insert_rowid() will return its internal row id, which is probably not what you want. The
correct way to establish a primary key migh look something like this look something like this:
create table some_table (id INTEGER PRIMARY KEY, some_field varchar(10))
Then you can try:
insert into some_table (some_field) values ('bob')
You will see that an id will be automatically generated and
calling sqlite_last_insert_rowid() will return the expected value
----
Manual Page -- http://www.php.net/manual/en/function.sqlite-last-insert-rowid.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51945
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51945&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51945&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51945&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51945&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51945&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51945&report=yes
Search -- http://master.php.net/manage/user-notes.php