Line 72:
Line 72:
= SQL rules =
= SQL rules =
+
* Structure of tables.
+
When you create a new table, it is recommanded to use same conventions than other Dolibarr tables. This means the following fields:
+
- rowid integer for id
+
- tms timestamp that will contains date of last modification (the database manage this field automaticaly, no need to manage it by the code, just create the field)
+
- import_key that will contains the import code YYYYMMDDHHMMSS if you make mass import.
+
Eventualy
+
- datec timestamp that is the creation date
+
- fk_user_creat integer that is the id of user making creation
+
- fk_user_modif integer that is the id of user making change
* All SELECT * are forbidden ! Any SELECT must define complete list of fields to get. This avoid confusion. Example:
* All SELECT * are forbidden ! Any SELECT must define complete list of fields to get. This avoid confusion. Example:
Line 87:
Line 96:
Note, problem of float numbers is same problem on all langauges and not only when inserting data into database. It occurs also with any language when you work on "real" numbers, so numbers must be, as soon as they are affected, cleaned with function price2num with second parameter defined to :
Note, problem of float numbers is same problem on all langauges and not only when inserting data into database. It occurs also with any language when you work on "real" numbers, so numbers must be, as soon as they are affected, cleaned with function price2num with second parameter defined to :
−
'MU', 'MT' or 'MS' depending on usage of number. (see function documentation)
+
'MU' (for unit prices), 'MT' (for total prices) or 'MS' (otherwise) depending on usage of number. (see function documentation)
Well, to be compatible with any accurency required by any country on amounts, we will use the following type into database:
Well, to be compatible with any accurency required by any country on amounts, we will use the following type into database: