Hello,
Le 19/06/2020 à 13:55, Darius Blaszyk via fpc-pascal a écrit :
Schema::create('flights', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('airline');
            $table->timestamps();
        });

I have something that looks a bit like this, a kind of ORM (sorry, part of my identifiers are in French, "champ" means "field")

... in the class declaration

  //champs persistants
  public
    nUser: Integer;
    nProject: Integer;
    Beginning: TDateTime; cBeginning: TChamp;
    End_     : TDateTime; cEnd      : TChamp;
    Description: String;

... in the implementation of the constructor :

     Champs.ChampDefinitions.NomTable:= 'Work';

     //champs persistants
     Integer_from_ ( nUser          , 'nUser'          );
     Integer_from_ ( nProject       , 'nProject'       );

     cBeginning:= DateTime_from_( Beginning      , 'Beginning'      );
     cBeginning.Definition.Format_DateTime:= 'yyyy/mm/dd" "hh:nn';

     cEnd:= DateTime_from_( End_           , 'End'            );
     cEnd.Definition.Format_DateTime:= 'yyyy/mm/dd" "hh:nn';

(this is extracted from class TblWork from https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/jsWorks/Elements/Work/ublWork.pas )

This class is for a row of the table "Work", most of the time, the instance is initialized by reading a row of dataset, but I've started some code to read from some other source, like android database or JSON data.

I've made a source code generator which can query the structure of a database, and generate source codes from templates. Particularly it can create the skeleton of unit ublWork.pas which contains class TblWork

My last release of source code generator is at : https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_03_30_Generateur_de_code

All the source is released under LGPL at https://github.com/jsuzineau/pascal_o_r_mapping/ , feel free to pick up code from it if you need.

--

Trader en karma

J'adore me regarder penser... ;-)

http://jean.suzineau.pagesperso-orange.fr/ : mes pages perso

http://www.mars42.com :  mes pages professionnelles, astronomie & informatique
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to