FieldsStr/FieldsExStr Field Retrieval

  1. 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.
  2. 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

  1. Suppose the user table has 4 fields: uid, nickname, passport, password.

  2. Retrieve fields:

    1. // uid,nickname,passport,password
    2. g.Model("user").FieldsStr()
  3. Retrieve fields with a specified prefix:

    1. // gf_uid,gf_nickname,gf_passport,gf_password
    2. g.Model("user").FieldsStr("gf_")

FieldsExStr Example

  1. Suppose the user table has 4 fields: uid, nickname, passport, password.

  2. Retrieve fields excluding some:

    1. // uid,nickname
    2. g.Model("user").FieldsExStr("passport, password")
  3. Retrieve fields excluding some with a specified prefix:

    1. // gf_uid,gf_nickname
    2. g.Model("user").FieldsExStr("passport, password", "gf_")