in reply to Re: SQLite: INSERT into a unique column and retrieve rowid
in thread SQLite: INSERT into a unique column and retrieve rowid
It does seem to me a lot of code
It could be streamlined for sure, particularly if you make the database enforce the uniqueness constraint (as in the OP) and just trap the exceptions. But really the worrying part is that $table and $column are SQL injections just waiting to happen.
Also the fact that you've used a state hash to hold the prepared statement handles means that these variables only have relevance on the first invocation, which is an unusual situation. eg. call it once on table foo and then again on table bar and the second one will still use table foo. That's confusing at best. (edit: ignore this part)
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: SQLite: INSERT into a unique column and retrieve rowid
by ibm1620 (Hermit) on May 05, 2024 at 20:42 UTC | |
by hippo (Archbishop) on May 06, 2024 at 10:23 UTC | |
|
Re^3: SQLite: INSERT into a unique column and retrieve rowid
by ibm1620 (Hermit) on May 05, 2024 at 01:47 UTC | |
by hippo (Archbishop) on May 05, 2024 at 10:55 UTC |