mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22:54 -06:00
reference SqlExp, SqlArray fixes
git-svn-id: svn://ultimatepp.org/upp/trunk@834 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6fe6597dfc
commit
cae2c0998f
3 changed files with 73 additions and 73 deletions
|
|
@ -1,70 +1,70 @@
|
|||
#include <SqlCtrl/SqlCtrl.h>
|
||||
#include <plugin/sqlite3/Sqlite3.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define MODEL <SQLArray/db.sch>
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_header.h"
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_source.h"
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_schema.h"
|
||||
|
||||
#define LAYOUTFILE <SqlArray/app.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
|
||||
struct App : public WithAppLayout<TopWindow> {
|
||||
EditString author;
|
||||
EditString title;
|
||||
EditString person;
|
||||
|
||||
App() {
|
||||
CtrlLayout(*this, "SqlArray SQL table editing example");
|
||||
master.SetTable(BOOK);
|
||||
master.AddKey(ID);
|
||||
master.AddColumn(AUTHOR, "Author").Edit(author);
|
||||
master.AddColumn(TITLE, "Title").Edit(title);
|
||||
master.Appending().Removing();
|
||||
master.SetOrderBy(AUTHOR, TITLE);
|
||||
|
||||
detail.SetTable(BORROW_RECORD);
|
||||
detail.AddKey(ID);
|
||||
detail.Join(BOOK_ID, master);
|
||||
detail.AddColumn(PERSON, "Borrowed by").Edit(person);
|
||||
detail.AddCtrl(BORROWED, borrowed);
|
||||
detail.AddCtrl(RETURNED, returned);
|
||||
detail.Appending().Removing();
|
||||
detail.SetOrderBy(PERSON);
|
||||
|
||||
master.Query();
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Sqlite3Session sqlite3;
|
||||
if(!sqlite3.Open(ConfigFile("simple.db"))) {
|
||||
Exclamation("Can't create or open database file\n");
|
||||
return;
|
||||
}
|
||||
SQL = sqlite3;
|
||||
SqlSchema sch(SQLITE3);
|
||||
sqlite3.SetTrace();
|
||||
All_Tables(sch);
|
||||
if(sch.ScriptChanged(SqlSchema::UPGRADE))
|
||||
Sqlite3PerformScript(sch.Upgrade());
|
||||
if(sch.ScriptChanged(SqlSchema::ATTRIBUTES))
|
||||
Sqlite3PerformScript(sch.Attributes());
|
||||
if(sch.ScriptChanged(SqlSchema::CONFIG)) {
|
||||
Sqlite3PerformScript(sch.ConfigDrop());
|
||||
Sqlite3PerformScript(sch.Config());
|
||||
}
|
||||
sqlite3.SetTrace();
|
||||
|
||||
App().Run();
|
||||
}
|
||||
#include <SqlCtrl/SqlCtrl.h>
|
||||
#include <plugin/sqlite3/Sqlite3.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define MODEL <SqlArray/db.sch>
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_header.h"
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_source.h"
|
||||
|
||||
#define SCHEMADIALECT <plugin/sqlite3/Sqlite3Schema.h>
|
||||
#include "Sql/sch_schema.h"
|
||||
|
||||
#define LAYOUTFILE <SqlArray/app.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
|
||||
struct App : public WithAppLayout<TopWindow> {
|
||||
EditString author;
|
||||
EditString title;
|
||||
EditString person;
|
||||
|
||||
App() {
|
||||
CtrlLayout(*this, "SqlArray SQL table editing example");
|
||||
master.SetTable(BOOK);
|
||||
master.AddKey(ID);
|
||||
master.AddColumn(AUTHOR, "Author").Edit(author);
|
||||
master.AddColumn(TITLE, "Title").Edit(title);
|
||||
master.Appending().Removing();
|
||||
master.SetOrderBy(AUTHOR, TITLE);
|
||||
|
||||
detail.SetTable(BORROW_RECORD);
|
||||
detail.AddKey(ID);
|
||||
detail.Join(BOOK_ID, master);
|
||||
detail.AddColumn(PERSON, "Borrowed by").Edit(person);
|
||||
detail.AddCtrl(BORROWED, borrowed);
|
||||
detail.AddCtrl(RETURNED, returned);
|
||||
detail.Appending().Removing();
|
||||
detail.SetOrderBy(PERSON);
|
||||
|
||||
master.Query();
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Sqlite3Session sqlite3;
|
||||
if(!sqlite3.Open(ConfigFile("simple.db"))) {
|
||||
Exclamation("Can't create or open database file\n");
|
||||
return;
|
||||
}
|
||||
SQL = sqlite3;
|
||||
SqlSchema sch(SQLITE3);
|
||||
sqlite3.SetTrace();
|
||||
All_Tables(sch);
|
||||
if(sch.ScriptChanged(SqlSchema::UPGRADE))
|
||||
Sqlite3PerformScript(sch.Upgrade());
|
||||
if(sch.ScriptChanged(SqlSchema::ATTRIBUTES))
|
||||
Sqlite3PerformScript(sch.Attributes());
|
||||
if(sch.ScriptChanged(SqlSchema::CONFIG)) {
|
||||
Sqlite3PerformScript(sch.ConfigDrop());
|
||||
Sqlite3PerformScript(sch.Config());
|
||||
}
|
||||
sqlite3.SetTrace();
|
||||
|
||||
App().Run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue