|
|
| Line 454: |
Line 454: |
| *创建要在命令行上运行的脚本的代码示例 '''skeleton_script.php''' | | *创建要在命令行上运行的脚本的代码示例 '''skeleton_script.php''' |
|
| |
|
| Use it as an example.
| | 请注意,PHP代码生成器([[Module ModuleBuilder|ModuleBuilder模块]])也使用这些框架,该模块在Dolibarr模块开发章节中有描述,用以提高您的开发速度。 |
| Note that the skeletons are also used by the PHP code generator, which is described in the development chapter of Dolibarr modules, to speed up your development.
| |
|
| |
|
| ==日期和时区== | | ==日期和时区== |
| Dolibarr is an application that is multi-user and multi-location. It's therefore necessary to store dates in the right format. To avoid problems with conversions, the following rules should be applied:
| | Dolibarr是一个多用户和多地域应用程序。因此,应以正确的格式存储日期。为避免转换出现问题,应遵循以下规则: |
|
| |
|
| *A date into memory must always be stored with Timestamp GMT format. | | *内存中的日期必须采用GMT时间戳格式。 |
| *A date stored into database, is the GMT Timestamp of date submitted into the request usng the <b>PHP server</b> timezone. This does not apply to date update automatically by database (fields '''tms''' into database). | | *存储在数据库中的日期包含来自'''PHP服务器本地时间'''请求中提交的日期的时间戳。这不适用于数据库自动更新的日期(数据库中的 '''tms''' 字段)。 |
|
| |
|
| For exemple le 1st january 1970, 3 hour at Paris (TZ=+1) = 2 hour at Greenwitch (TZ=0) will be stored into memory with value 7200 and will be submitted into a SQL request to database with the string '19700101030000' (PHP convert into its TZ hour and database will unconvert it using its timezone too that is same than PHP).
| | 例如:1970年1月1日巴黎时间的3点钟(TZ=+1)= 1970年1月1日格林威治时间的2点钟(TZ=0),其存储在内存中的值都是7200,并将以字符串“19700101030000”的形式提交给数据库(PHP将其转换为TZ的时间值,而数据库再将其转换回PHP服务器时区的时间)。 |
|
| |
|
| All select methods should translate date fields, that are with format TZ of database ('19700101030000'), into a timestamp field by calling the method db->jdate. This is to store into memory a GTM Timestamp date. All insert methods must convert, during generation of SQL request, the memory date into the string by using db->idate (you may find examples into skeleton).
| | 因此,所有 select 方法都必须通过调用 db->jdate 函数来转换日期字段,将其从数据库读取的TZ格式日期字段('19700101030000')转换成GMT时间戳格式,以便以GMT时间戳格式检索内存中的信息。而在生成SQL语句时,所有 insert 方法都必须通过调用 db->idate 函数将已知内存格式日期转换为字符串格式日期(参见框架生成的示例)。 |
|
| |
|
| *Dates that are updated automatically (field '''tms''' into database) contains a GMT Timestamp GMT of date when change is done. The select will also use the db->jdate (that use PHP server TZ) to convert read data into a GMT Timestamp into memory. So if timezone of database differs from timezone of PHP server (one of them is not correctly set), you may experience differences between creation date and update date. | | *数据库自动更新的日期字段(数据库中的 '''tms''' 字段)存放根据数据库时区进行转换的时间戳。select 方法通过调用 db->jdate 以GMT时间戳格式检索内存中的数据。如果数据库时区与PHP时区不同(其中一个设置不正确),则创建日期和修改日期之间可能会存在差异。 |
|
| |
|
| *Manipulation date with PHP must be done using the Dolibarr date functions: '''dol_now(), dol_mktime(), dol_stringtotime(), dol_getdate(), dol_time_plus_duree()'''. You may also find other functions available into file '''date.lib.php'''. | | *PHP中的日期操作必须使用 dolibarr 中的日期函数:'''dol_now()、dol_mktime()、dol_stringtotime()、dol_getdate()、dol_time_plus_duree()。'''您还可以在文件 '''date.lib.php''' 中找到其他现成的可用函数。 |
|
| |
|
| ==UTF8/ISO 编码== | | ==UTF8/ISO 编码== |