StupidBeauty
Read times:600Posted at:Mon Mar 4 02:31:12 2013
- no title specified

Wt3.2.3文档翻译:数据库对象(Wt::Dbo),Database Objects (Wt::Dbo)

函数文档

template<class Action , typename V >

void Wt::Dbo::field

(

Action &

action,

V &

value,

const std::string &

name,

int

size = -1

)

映射一个数据库对象字段。

此函数将 value 字段绑定 到数据库字段 name

可选参数size ,用来建议使用指定 的存储空间。 它只对 std::string Wt::WString 类型的字段有用, 会导致在数据库模式中使用 varchar(size) 来储存此字段,而不是使用 一种无限长度的字符串类型。

妳可能需要特化此函数, 以处理这种类型: 一种特殊的复合(composite)类型, 它应当被持久化存储到多个数据库字段中,但是不应当存储 一个单独的表(例如:自然 natural )复合主键,参考 id() )。

示例:

struct Coordinate {

int x, y;

};

namespace Wt {

namespace Dbo {

template <class Action>

void field(Action& action, Coordinate& coordinate, const std::string& name, int size = -1)

{

field(action, coordinate.x, name + "_x");

field(action, coordinate.y, name + "_y");

}

} // namespace Dbo

} // namespace Wt

要想将 一个自定义类型持久化为一个单个的字段 的话, 妳应当特化 sql_value_traits

未知美女

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands