sqlYoga: sqlite primary key and a few detailed questions
David Bovill
david at vaudevillecourt.tv
Tue Apr 6 13:44:51 EDT 2010
I've had some time to start implementing the local handler database in
sqlYoga: and have noticed a couple of things:
1. An sqlite table "handler" db with a field "id" set as a primary key
does not show in the db schema of sqlYoga. Do I have to script this using
something ike "sqlrecord_set theRecordA, "id", theProjectID" - and if so
using a model behavior called when the table is created?
2. How do I delete multiple records - can;t find an example to learn from
- I'm trying something along the lines of:
-- put "id is in :1" into theParamsA ["conditions"]
-- put "1,2" into theParamsA ["condition bindings"]["1"]
put "handler.object is ':1'" into theParamsA ["conditions"]
put someObject into theParamsA ["condition bindings"]["1"]
sqlrecord_find "handler", theParamsA, theRecordsA
sqlrecord_delete theRecordA
But I'm only getting one record returned in theRecordsA. Does anyone have a
code snippet for deleting multiple records?
I'd also love to know a little about how to pass the arrays around between
"objects" - I'm digging into the innards of the arrays now, but it would be
great to have some more examples? Like how do you take an array from
sqlquery_X and use it with sqlrecord_
Finally in the example below:
put sqlrecord_createObject("projects") into theRecordA
>
> ## Fill in primary key field for 'projects'
> sqlrecord_set theRecordA, "id", theProjectID
>
> ## Delete record
> sqlrecord_delete theRecordA put the result into theError
>
does - "sqlrecord_set theRecordA, "id", theProjectID" really set the
primary key - it is not in the API documentation, or is it something
specific to the record object?
More information about the use-livecode
mailing list