Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use field in thinkphp

Shulou Source: shulou.com Published: 2022-06-03 17:42:21 11月13日 Update

This article mainly introduces how to use field in thinkphp. It is very detailed and has a certain reference value. Friends who are interested must finish it!

Description

The field method is one of the coherent operation methods of the model, and its main purpose is to identify the fields to be returned or manipulated, which can be used for query and write operations.

Example

Specify the field Db::table ('think_user')-> field (' id,title,content')-> select ()

Segment setting alias

Db::table ('think_user')-> field (' id,nickname as name')-> select ()

Use function

Db::table ('think_user')-> field (' id,SUM (score)')-> select (); use array parameter Db::table ('think_user')-> field ([' id','title','content'])-> select (); array parameter-alias Db::table ('think_user')-> field ([' id','nickname'= > 'name'])-> select (); function + array mode

Db::table ('think_user')-> field ([' id','concat (name, "-", id)'= > 'truename','LEFT (title,7)' = > 'sub_title'])-> select (); get all fields Db::table (' think_user')-> select (); Db::table ('think_user')-> field (' *')-> select (); Db::table ('think_user')-> field (true)-> select () Fields exclude Db::table ('think_user')-> field (' content',true)-> select (); Db::table ('think_user')-> field (' user_id,content',true)-> select (); Db::table ('think_user')-> field ([' user_id','content'], true)-> select (); above is all the content of the article "how to use field in thinkphp". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Fields arrays contents functions aliases parameters methods articles values interests guys partners ways more identities models purposes knowledge examples industries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Apple vpn NVidia Huawei