Hi Sam,
EDA does provide some controls which makes it easy to build a GUI to edit database fields.
For example the ListSection / EditSection system which is used by the extras/genericEditor and in that MovieCollection sample, the generic FieldDataBox, and the more specific controls e.g. TableDropBox, DropDataBox, EditDropDataBox, FieldCheckButton, FieldDropDataBox, EditFieldDropDataBox.
But you are in no way tied to use the GUI, the main EDA API is just database access.
The core EDA classes are DataSource, Database, Table, Field and Row.
You open a database from a data source, and you can open a table from a database.
The Row class is used to add new rows, query existing contents or update contents.
With the SQLite driver you can use SQL language with Row::Query().
You can also use the eC active records system to access the database in an object oriented manner.
Usually when building an EDA app you will write your database schema using the dbtable keyword. (See movieSchema.ec)
This will list all fields in each table, with their type, the name in the database, and the identifier to use when acessing them OO style. This will also automatically create these row classes specific to each table. e.g. defininig the dbtable "Movies" automatically create both a RowMovies class as well as a Movie identifier class.
There are actually plans to make this more obvious by revising the dbtable keyword in favor of declaring it as a class (
http://ecere.com/mantis/view.php?id=515 )
I suggest you take a look at the accompanying slides for that sample at
https://github.com/ecere/ecere-sdk/raw/ ... tation.odp if you haven't already.
But here are some key points:
Code: Select all
RowMovies r { };
r.Add(); // This would add a new row to the "Movies" table
r.name = "Crouching Tiger, Hidden Dragon"; // This sets an entry, the name property is automatically set up in the RowMovies class
delete r;
You could also use the generic Row class to do this but it would be more work:
Code: Select all
Row r { table = dbtable("Movies") };
r.Add();
r.SetData(dbfield("Movies", name);
delete r;
This still relies on having a schema however.
If you're trying to open a SQLite table that was not created with EDA and a schema, you'd need to do something like:
Code: Select all
DataSource ds { driver = "SQLite" };
Database db = ds.OpenDatabase("someDB.sqlite", no);
Table tbl = db.OpenTable("MyTable", { tableRows });
Field fld = tbl.FindField("SomeField");
Row r { tbl = tbl };
String name = null; // If we have a string field
r.sysID = rowIDtoOpen; // Or you can use while(r.Next()) to iterate through all rows...
r.GetData(fld, name);
However, the support to auto-generate the eda_table_fields table (which lists fields in all table with their types) from the SQLite schema (sqlite_master table) seems to either be broken or have some limitations at the moment.
Please let me know whether this helps and if you have any further questions
Best regards,
-Jerome