Where to store database ID
Devin Asay
devin_asay at byu.edu
Thu Jul 25 17:45:24 EDT 2013
On Jul 25, 2013, at 10:45 AM, Mike Kerner wrote:
> LC's libraries need the ID so they know what you're asking them for after
> you've opened the DB. I just use globals. You can use a global with
> multiple lines, or an array with multiple elements, if you are going to
> have multiple DB's open. I THINK that the ID's are sequential and "unique"
> per launch of LC, not per time the stack is opened, but don't quote me on
> that. Jacque?
Not Jacque, but I saw her once. :)
DBIDs are numbered sequentially and increment each time you make a connection. Creating a DB cursor also affects this number. E.g.:
revOpenDatabase --> connection id is 1
revQueryDatabase --> cursor id is 2
revCloseDatabase
revOpenDataabase --> connection id is 3
Others probably have their own approach, but I rarely leave a DB connection open for an entire session. I create the connection, do my transaction, then close it immediately. Maybe it's the "wrong" way, but it works well for the way I use DBs. YMMV.
Regards,
Devin
Devin Asay
Learn to code with LiveCode University
http://university.livecode.com
More information about the use-livecode
mailing list