31,021
edits
| Line 87: | Line 87: | ||
</source> | </source> | ||
* Into SQL requests, you must quote fields except fields that contains amounts that must be stored as double or real type. Quotes on numbers may results in saving a different value. For example 412.62 in an insert will be saved with value 412.61999512 into database | * Into SQL requests, you must quote fields except fields that contains amounts that must be stored as double or real type. Quotes on numbers may results in saving a different value. For example 412.62 in an insert will be saved with value 412.61999512 into database (due to implicit conversion string to numeric) if target field has type double(24,8). Only PHP see value 412.61999512. Other tools will see 412.62 giving sensation that there is no problem. But it's PHP that hase the good vision. There is really a wrong value into database. By removing quotes on numbers, no problem occurs. | ||
Example: | Example: | ||
| Line 98: | Line 98: | ||
'MU' (for unit prices), 'MT' (for total prices) or 'MS' (otherwise) 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: | * Type of fields: | ||
Well, to be compatible with any accurency required by any country on amounts, and with any database syntax, we will use the following type into database: | |||
- double(24,8) for any amount | - double(24,8) for any amount | ||
- double(6,3) for any vat rate | - double(6,3) for any vat rate | ||
- real for a quantity | - real for a quantity | ||
- varchar for a string (alos if length is 1, the type char is more and more deprecated) | |||
- timestamp for a field date+time that is automatically updated | |||
- datetime for a field date+tie | |||
- date for a field date | |||
* Dolibarr must works even if Mysql option '''strict''' is active. | * Dolibarr must works even if Mysql option '''strict''' is active. | ||