FieldsStr/FieldsExStr
Field Retrieval
FieldsStr
is used to retrieve fields of a specified table, with an optional field prefix. The fields are returned as a string, concatenated using a "," symbol.FieldsExStr
is used to retrieve fields from a specified table, excluding certain fields, with an optional field prefix. The fields are returned as a string, concatenated using a "," symbol.
FieldsStr
Example
-
Suppose the
user
table has 4 fields:uid
,nickname
,passport
,password
. -
Retrieve fields:
// uid,nickname,passport,password
g.Model("user").FieldsStr() -
Retrieve fields with a specified prefix:
// gf_uid,gf_nickname,gf_passport,gf_password
g.Model("user").FieldsStr("gf_")
FieldsExStr
Example
-
Suppose the
user
table has 4 fields:uid
,nickname
,passport
,password
. -
Retrieve fields excluding some:
// uid,nickname
g.Model("user").FieldsExStr("passport, password") -
Retrieve fields excluding some with a specified prefix:
// gf_uid,gf_nickname
g.Model("user").FieldsExStr("passport, password", "gf_")