MiniORMUtils
Version: 1.14
Demo
Version: 1.03
This library can be use for creating db schema and performing CRUD operations.
It is suitable for Web API Template or any database system.
Currently it supports SQLite and MySQL (B4J).
A B4XPages Demo project attached. It is a modified app from Web API Client but use local SQLite. For B4J, it can be modified to connect to MySQL database.
Note: For SQLite, change DBName to DBFile if using MiniORMUtils v1.12+
Initialization
Create Table
Insert Data
Execute Batch NonQuery
Select All Rows
Joining Table
GitHub:
https://github.com/pyhoon/MiniORMUtils-B4X
https://github.com/pyhoon/MiniORM-Demo-B4X
Version: 1.14
Demo
Version: 1.03
This library can be use for creating db schema and performing CRUD operations.
It is suitable for Web API Template or any database system.
Currently it supports SQLite and MySQL (B4J).
A B4XPages Demo project attached. It is a modified app from Web API Client but use local SQLite. For B4J, it can be modified to connect to MySQL database.
Note: For SQLite, change DBName to DBFile if using MiniORMUtils v1.12+
B4X:
con.DBFile = "MiniORM.db"
Initialization
B4X:
Dim MDB As MiniORM
MDB.Initialize(Main.DBOpen, Main.DBEngine)
MDB.UseTimestamps = True
MDB.AddAfterCreate = True
MDB.AddAfterInsert = True
Take note: Before calling MDB.Create and MDB.Insert, set AddAfterCreate and AddAfterInsert to True.
Create Table
B4X:
MDB.Table = "tbl_category"
MDB.Columns.Add(MDB.CreateORMColumn2(CreateMap("Name": "category_name")))
MDB.Create
Insert Data
B4X:
MDB.Columns = Array("category_name")
MDB.Insert2(Array("Hardwares"))
MDB.Insert2(Array("Toys"))
Execute Batch NonQuery
B4X:
Wait For (MDB.ExecuteBatch) Complete (Success As Boolean)
If Success Then
Log("Database is created successfully!")
Else
Log("Database creation failed!")
Log(LastException)
End If
MDB.Close
Select All Rows
B4X:
MDB.Table = "tbl_category"
MDB.Query
Dim Items As List = MDB.Results
Joining Table
B4X:
MDB.Table = "tbl_products p"
MDB.Select = Array("p.*", "c.category_name")
MDB.Join = MDB.CreateORMJoin("tbl_category c", "p.category_id = c.id", "")
MDB.WhereValue(Array("c.id = ?"), Array As String(CategoryId))
MDB.Query
Dim Items As List = MDB.Results
GitHub:
https://github.com/pyhoon/MiniORMUtils-B4X
https://github.com/pyhoon/MiniORM-Demo-B4X
Attachments
Last edited: