Saving Fld Descript Content back to Descript DB...Best way ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Saving Fld Descript Content back to Descript DB...Best way ?

Post by liveme » Fri Mar 19, 2021 12:22 am

Hi ppl,

I'm dealing with this stack field behaviour that acts as a local content storage...
While being practical sometimes this could create unsynchronized content with an underlaying DB.

First, I'm puling content from an Sqlite DB "Titles Table" in order to populate a List of Titles displayed as a DG.

A field from another table just contain long Descriptions that are also pulled out from a 2nd Description DB Table.
(Both tables share a common field value)


Each time a user click on any Title it retreives and populate the Description field below with a related content.

Since the Description content is left editable (on purpose), it can be modified at any time by the user...
- How could one force an update process towards the Sqlite content so that any time a content is being modified,
the Sqlite DB will be syncronized behind transparently, after the edit process is ended. (or meanwhile ???)

I am worried that a user could decide to click an App menu button "X" and instantly quit an App probably leaving its new content in the Stack field but an outdated content (unmodified yet) in the DB !! :shock: ...and this newer extra content will probably be overwriten the next time that its corresponding title is called again. :|
Any prooved method to deal with this event ?
Tks
Terii

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Saving Fld Descript Content back to Descript DB...Best way ?

Post by stam » Fri Mar 19, 2021 2:29 am

Hi Terii

Not sure i fully understand but have some comments (off the top of my head -- no guarantees ;))
  • if the correspondence of titles to descriptions is 1 to 1, then you should not be using 2 tables for this, should be just 1. Or does 1 title have multiple descriptions?
  • You'll probably want to load titles and descriptions at the same time; store them in an persistent array (a script or global variable, custom property etc). That way you don't need to fire off a new query each time the user clicks a description (if i understood you correctly - apologies if not)
  • I would probably recommend the on closeField handler to update the descriptions in the sqlite db if you want to do this without user action; when the user exits the field and it's text has changed it will fire of that message and you can use this to update
  • You can update on closeCard - so the red x isn't an issue, it will update when the user leaves the card/quits the app. Only thing that will prevent this is if the app crashes i guess
does that help?

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: Saving Fld Descript Content back to Descript DB...Best way ?

Post by liveme » Fri Mar 19, 2021 3:12 am

Hi Stam,
Thanks, yes, If onclose card and field do their job that would defenitely be my choice..when apps crash most anyone would expect to suffer some lost.
(maybe I can code some save to DB after n characters to limit even more those lost)

As for the rest, yes I'm leaving open a one Title to a many descriptions scheme - it has very interesting Pros, so I'm keeping titles/descriptions splited in two tables most likely. Each Title being just 1 record, it will always benefit this table loading speed !
As of now, firering a description query is an instant process (1 to 12 ms) ...being very few lines in both table.

I'll grab more dummy data latter on to measure more load lags...
Thanks again for the commands - testing this right now !
Good coding !
:idea: :wink:

liveme
Posts: 240
Joined: Thu Aug 27, 2015 5:22 pm
Location: down under

Re: Saving Fld Descript Content back to Descript DB...Best way ?

Post by liveme » Fri Mar 19, 2021 8:45 am

wuuuhuu, the on closefield was coded in a really smart way, only trigged if st has been changed !
very cool ! :wink:
:P

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”