![]() |
[Server] ORM - Printable Version +- Gothic Online Forums (https://archive.gothic-online.com) +-- Forum: Scripting (English) (https://archive.gothic-online.com/forum-11.html) +--- Forum: Resources (https://archive.gothic-online.com/forum-14.html) +---- Forum: Scripts (https://archive.gothic-online.com/forum-17.html) +---- Thread: [Server] ORM (/thread-2762.html) |
[Server] ORM - Quarchodron - 01.07.2020 ORM build for Gothic 2 Online works with: MySql Module(V.0.3) Test version! (Be aware that it's not been tested in real environment) Link to file !Report Error here Script contains 4 main elements - Active Record with control ur model creation save/modify - Connector with is simples of all. Allows to create connection with database. - Builder starting from phrase Query() with allows user to create most of operation simply by using functions builded in. - Migration module allows user to create sql queries only one time. Active Record Build in base of query builder use some of features to controll proces of creating new model and update him. Allows also to easy find and use models base on table. Contains also some function to control rules for fields in table. (Validation). With this model you can easily create e.g. Player class or House. Connector Contain simple function to build query like queryGetAll, queryGet and some basics stuff to operate on Database. Build on Class you can directly use 2 databases in same time. If u dont wanna use Builder/Active Record u should use basiclly just this class to controll your connection and quer'ies. Code: local db = Connector(host, user, pass, db, port); Builder Builder allows user to create query command simply by use builded functions. (Fast way to create query). Remember to have on mind that is only alpha version. I need to build more functions. Code: local query = Query(); Migration Simple class contain controll of creating new table / inserts or just changes in database. Changes is saved in table 'migrations' with allows to not build same changes twice. Code: local mig = Migration(); RE: [Server] ORM - Patrix - 01.07.2020 Is it good idea to use strings as a part of the query? This approach doesn't enforce building the 'correct' queries to the database. If someone will make a typo in a string, then finding the cause of the problems can be really difficult. RE: [Server] ORM - Quarchodron - 01.07.2020 Actually active record use name of fields in building query. So IT worka another way. Problem is in building query other way than from model. Using query() u have to be aware that if u make mistake u will get error. Every modern orm Using that in that way. You get more possible ways to build a query. Ofc. You csn do some damage. But in future of this orm probably user will not use query builder seperate from active record at all. To remove SQL injection u have to Just use builded function grom module. RE: [Server] ORM - Quarchodron - 08.07.2020 Update@ Version 0.2 - Add rules/validation for orm - New types in Builder - New module migration - Fixes in orm |