使用 Haxe 将 SDateTime 存储在 SQL 数据库中

Store SDateTime in SQL database using Haxe

我目前正在使用 Haxe 创建数据库,table 用于存储游戏数据。

我有一个时间戳字段。我正在使用以下内容:

class GameData extends Object {
    public var id : SId;
    public var username : SString<32>;
    public var countryA2 : SString<32>;
    public var scoreFor : SInt;
    public var scoreAgainst : SInt;
    public var scoreDifference : SInt;
    public var ts : SDateTime;
}

然后我尝试使用

填充此字段
gameData.ts = Date.now();

但是所有这些 returns 都是 "Date" 而不是数字中的实际日期。

然后我尝试了 DateTools.format() class 并生成了这个:

DateTools.format(Date.now(), "%Y-%m-%d %H:%M:%S")

其中给我的date/time如下:2016-11-2519:17:13

但是试图将其存储在字段中只是 returns 一个错误:

String should be sys.db.SDateTime

通过 Haxe 在 SQL 数据库中存储 date/time 的理想方式是什么?

谢谢。

可能你应该使用 gameData.ts.toString() 或其他数据方法 'to get numbers' 查看 https://github.com/ufront/ufront-orm where you find http://old.haxe.org/manual/spod 'still the best resource' 以获取 Haxe 的 sys.db.* DB 类 和宏 google for 'haxe SPOD' - 'sys.db package contains also the new version for SPOD' - SPOD 相关示例可能仍 sys.db 兼容 - f.e。 this

现在设法解决了它,fresh day 似乎奇怪地允许 Date.now() 工作。感谢大家的帮助。