<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hello,<br>
</div>
<div class="moz-cite-prefix">Le 19/06/2020 à 13:55, Darius Blaszyk
via fpc-pascal a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CAOOn3iTNhPRzJTSeSoOBidj4o5q4LGuydffw7rG_+wCvZwkGhw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr"><code class="gmail-language-php"><span
class="gmail-token gmail-php gmail-language-php"> Schema<span
class="gmail-token gmail-punctuation">:</span><span
class="gmail-token gmail-punctuation">:</span><span
class="gmail-token gmail-function">create</span><span
class="gmail-token gmail-punctuation">(</span><span
class="gmail-token gmail-single-quoted-string
gmail-string">'flights'</span><span class="gmail-token
gmail-punctuation">,</span> <span class="gmail-token
gmail-keyword">function</span> <span class="gmail-token
gmail-punctuation">(</span>Blueprint <span
class="gmail-token gmail-variable">$table</span><span
class="gmail-token gmail-punctuation">)</span> <span
class="gmail-token gmail-punctuation">{</span>
</span></code>
<div>
<pre class="gmail-language-php"><code class="gmail-language-php"><span class="gmail-token gmail-php gmail-language-php"> <span class="gmail-token gmail-variable">$table</span><span class="gmail-token gmail-operator">-</span><span class="gmail-token gmail-operator">></span><span class="gmail-token gmail-function">id</span><span class="gmail-token gmail-punctuation">(</span><span class="gmail-token gmail-punctuation">)</span><span class="gmail-token gmail-punctuation">;</span>
<span class="gmail-token gmail-variable">$table</span><span class="gmail-token gmail-operator">-</span><span class="gmail-token gmail-operator">></span><span class="gmail-token gmail-function">string</span><span class="gmail-token gmail-punctuation">(</span><span class="gmail-token gmail-single-quoted-string gmail-string">'name'</span><span class="gmail-token gmail-punctuation">)</span><span class="gmail-token gmail-punctuation">;</span>
<span class="gmail-token gmail-variable">$table</span><span class="gmail-token gmail-operator">-</span><span class="gmail-token gmail-operator">></span><span class="gmail-token gmail-function">string</span><span class="gmail-token gmail-punctuation">(</span><span class="gmail-token gmail-single-quoted-string gmail-string">'airline'</span><span class="gmail-token gmail-punctuation">)</span><span class="gmail-token gmail-punctuation">;</span>
<span class="gmail-token gmail-variable">$table</span><span class="gmail-token gmail-operator">-</span><span class="gmail-token gmail-operator">></span><span class="gmail-token gmail-function">timestamps</span><span class="gmail-token gmail-punctuation">(</span><span class="gmail-token gmail-punctuation">)</span><span class="gmail-token gmail-punctuation">;</span>
<span class="gmail-token gmail-punctuation">}</span><span class="gmail-token gmail-punctuation">)</span><span class="gmail-token gmail-punctuation">;</span></span></code></pre>
</div>
</div>
</blockquote>
<p>I have something that looks a bit like this, a kind of ORM
(sorry, part of my identifiers are in French, "champ" means
"field")<br>
</p>
<p>... in the class declaration<br>
</p>
<pre><code><font size="3" face="Courier New"><font color="black"><font color="red"> </font>//champs persistants
<b>public
</b><font color="blue">nUser</font><font color="red">: </font><font color="blue">Integer</font><font color="red">;
</font><font color="blue">nProject</font><font color="red">: </font><font color="blue">Integer</font><font color="red">;
</font><font color="blue">Beginning</font><font color="red">: </font><font color="blue">TDateTime</font><font color="red">; </font><font color="blue">cBeginning</font><font color="red">: </font><font color="blue">TChamp</font><font color="red">;
</font><font color="blue">End_ </font><font color="red">: </font><font color="blue">TDateTime</font><font color="red">; </font><font color="blue">cEnd </font><font color="red">: </font><font color="blue">TChamp</font><font color="red">;
</font><font color="blue">Description</font><font color="red">: </font><b>String</b><font color="red">;
</font></font></font></code></pre>
<p>... in the implementation of the constructor :</p>
<pre><code><font size="3" face="Courier New"><font color="black"><font color="red"> </font><font color="blue">Champs</font><font color="red">.</font><font color="blue">ChampDefinitions</font><font color="red">.</font><font color="blue">NomTable</font><font color="red">:= </font>'Work'<font color="red">;
</font>//champs persistants
<font color="blue">Integer_from_ </font><font color="red">( </font><font color="blue">nUser </font><font color="red">, </font>'nUser' <font color="red">);
</font><font color="blue">Integer_from_ </font><font color="red">( </font><font color="blue">nProject </font><font color="red">, </font>'nProject' <font color="red">);
</font><font color="blue">cBeginning</font><font color="red">:= </font><font color="blue">DateTime_from_</font><font color="red">( </font><font color="blue">Beginning </font><font color="red">, </font>'Beginning' <font color="red">);
</font><font color="blue">cBeginning</font><font color="red">.</font><font color="blue">Definition</font><font color="red">.</font><font color="blue">Format_DateTime</font><font color="red">:= </font>'yyyy/mm/dd" "hh:nn'<font color="red">;
</font><font color="blue">cEnd</font><font color="red">:= </font><font color="blue">DateTime_from_</font><font color="red">( </font><font color="blue">End_ </font><font color="red">, </font>'End' <font color="red">);
</font><font color="blue">cEnd</font><font color="red">.</font><font color="blue">Definition</font><font color="red">.</font><font color="blue">Format_DateTime</font><font color="red">:= </font>'yyyy/mm/dd" "hh:nn'<font color="red">;
</font></font></font></code></pre>
<p>(this is extracted from class TblWork from <a
moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/jsWorks/Elements/Work/ublWork.pas">https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/jsWorks/Elements/Work/ublWork.pas</a>
)</p>
<p>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.<br>
</p>
<p>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<br>
</p>
<p>My last release of source code generator is at : <a
moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_03_30_Generateur_de_code">https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_03_30_Generateur_de_code</a><br>
</p>
<p>All the source is released under LGPL at
<a class="moz-txt-link-freetext" href="https://github.com/jsuzineau/pascal_o_r_mapping/">https://github.com/jsuzineau/pascal_o_r_mapping/</a> , feel free to
pick up code from it if you need.<br>
</p>
<p>-- </p>
<pre class="moz-signature" cols="72">Trader en karma
J'adore me regarder penser... ;-)
<a class="moz-txt-link-freetext" href="http://jean.suzineau.pagesperso-orange.fr/">http://jean.suzineau.pagesperso-orange.fr/</a> : mes pages perso
<a class="moz-txt-link-freetext" href="http://www.mars42.com">http://www.mars42.com</a> : mes pages professionnelles, astronomie & informatique
</pre>
</body>
</html>