delgadol
Member
Good day;
always ask me; if our B4A could have a data management tool at least SQLite; to help us handle many tables; no need to write SO MUCH repeated CODE; I have read and used the well-known ORMs on other platforms; that help us with the basic handling of tables in a database; This is how I set out to do a basic ORM for b4a; to help me with those basic tasks that cost me so much code, those tasks are always the same: insert, search, update, delete and count.
I have always thought that B4A is a wonderful tool; and as a community, it is necessary to make it grow and equip it with new tools; many wish you an Entity Framework; or something Beautiful (and magical) that allows us to handle data simply and elegantly.
When we manage data we usually define the Objects based on the tables Example:
Type TUser (id as int, name as string, address as string)
so typically our table would have 3 known data to be able to handle it
structure (object type)
name (of the table),
index field (required)
and of course a SQL object that points to our database ready and initialized;
I have called this class a generic data entity; since it is capable of adapting to the greatest number of situations that we need in the daily use of SQLite.
after them; initialized the class
this class has 2 objects to store data; item = when we make a query that returns a data; items (list of objects) when we make a query that involves multiple data; the item data and the contents in intems are data of the type that has been declared; THEY ARE NOT MAPS; if you have declared a USER with the previous characteristics; you can do searches like:
I currently have at least 8 high volume projects, and it has worked excellently for me;
I hope it will be of great help to all of you; And if you like to contribute to its maintenance, I accept donations; In the same way, I make a call to those who like to program and make B4X great so that we can make a better tool as a basis
Final Note: I need to modify the version of DBUtils; since the ExecuteMAp function returns the name of the fields in lowercase; and that caused me an error in 2 of my projects.
Thanks in advance
always ask me; if our B4A could have a data management tool at least SQLite; to help us handle many tables; no need to write SO MUCH repeated CODE; I have read and used the well-known ORMs on other platforms; that help us with the basic handling of tables in a database; This is how I set out to do a basic ORM for b4a; to help me with those basic tasks that cost me so much code, those tasks are always the same: insert, search, update, delete and count.
I have always thought that B4A is a wonderful tool; and as a community, it is necessary to make it grow and equip it with new tools; many wish you an Entity Framework; or something Beautiful (and magical) that allows us to handle data simply and elegantly.
When we manage data we usually define the Objects based on the tables Example:
Type TUser (id as int, name as string, address as string)
so typically our table would have 3 known data to be able to handle it
structure (object type)
name (of the table),
index field (required)
and of course a SQL object that points to our database ready and initialized;
I have called this class a generic data entity; since it is capable of adapting to the greatest number of situations that we need in the daily use of SQLite.
Initialized Data Setting:
' Clase DB Usuario --------------------------------
Type TUsersInfo ( _
ID As Int, _
nombre As String, _
cargo As String, _
email As String, _
rut As String, _
key As String, _
fcm As String _
)
Public TB_USERS As TUsersInfo
Public Const TB_USERS_NAME As String = "tb_user_info"
Public Const TB_USERS_INDEX As String = "ID"
' -------------------------------------------------
after them; initialized the class
TGeneric Entity Settings:
Public UsersEntity As TGenericEntity
' Starter.SrvSql = connection handle
' TB_USERS = base object table
' TB_USERS_NAME = table name
' TB_USERS_INDEX = table index name
UsersEntity.Initialize(Starter.SrvSql,TB_USERS,TB_USERS_NAME,TB_USERS_INDEX)
this class has 2 objects to store data; item = when we make a query that returns a data; items (list of objects) when we make a query that involves multiple data; the item data and the contents in intems are data of the type that has been declared; THEY ARE NOT MAPS; if you have declared a USER with the previous characteristics; you can do searches like:
First Use TGenericEntity:
If(UsersEntity.getByID(314)) Then
Dim client As TUsersInfo = UsersEntity.item.As(TUsersInfo)
End If
I currently have at least 8 high volume projects, and it has worked excellently for me;
I hope it will be of great help to all of you; And if you like to contribute to its maintenance, I accept donations; In the same way, I make a call to those who like to program and make B4X great so that we can make a better tool as a basis
Final Note: I need to modify the version of DBUtils; since the ExecuteMAp function returns the name of the fields in lowercase; and that caused me an error in 2 of my projects.
Thanks in advance