Little plum: A database table for demonstration purposes:customers
Official Interpretation: "Reading a dataset is actually getting multiple rows of records (and associated data) in a data table, using select
the method"
1 $customers=d (' customers '); 2 $customers _msg_all=$customers, select (); 3 Print_r ($customers _msg_all); die;
The simplest, no-brains, Select data is as follows:
1 Array2 (3 [0] = = Array4 (5 [id] =6 [brand_id] =7 [Name] = Anme8 [Iccid] = 1882***9 [Mobile] = 18826**Ten [Addtime] = One [Pretime] = A [Taocan] = - [Huafei] = - [Liuliang] = the [Beizhu] = - [Huzhaoid] = 3660 - [Rutaiid] = 3660 - [Tongxingid] = 3660 + [status] = 0 - [des] = + [tongxingimg] = 2016-08-15/57b19aaeb008c.png A [rutaiimg] = 2016-08-15/57b19aaeaf58e.png at ) - - [1] = = Array - ( - [id] = - [brand_id] = + in [name] =>ads - [Iccid] = 132**21 to [Mobile] = 138***1 + [Addtime] = - [Pretime] = the [Taocan] = * [Huafei] = $ [Liuliang] =Panax Notoginseng [Beizhu] = - [Huzhaoid] = 123456 the [Rutaiid] = 123456 + [Tongxingid] = 123456 A [status] = 0 the [des] = + [tongxingimg] = 2016-08-15/57b19acc5b4a5.png - [rutaiimg] = 2016-08-15/57b19acc5a9e6.png $ ) $ - [2] = = Array - ( the [id] = - [brand_id] =Wuyi [Name] = Kils the [Iccid] = 1890** - [Mobile] = 189*** Wu [Addtime] = - [Pretime] = About [Taocan] = $ [Huafei] = - [Liuliang] = - [Beizhu] = - [Huzhaoid] = 123123 A [Rutaiid] = 3213123 + [Tongxingid] = 321312 the [status] = 0 - [des] = $ [tongxingimg] = 2016-08-15/57b19bef2b9db.png the [rutaiimg] = 2016-08-15/57b19bef2ae22.png the ) the the)
Official Interpretation:"read data refers to reading a row of data in the data table (or associated data), mainly through find
the method of completion":
Now look at the data found in find :
1 $customers=d (' customers '); 2 $customers _msg_all=$customers, find (); 3 Print_r ($customers _msg_all); die;
1 Array2 (3 [id] =4 [brand_id] =5 [Name] = Jiangjun6 [Iccid] = 1882**07 [Mobile] = 1882***08 [Addtime] =9 [Pretime] =Ten [Taocan] = One [Huafei] = A [Liuliang] = - [Beizhu] = - [Huzhaoid] = 3660 the [Rutaiid] = 3660 - [Tongxingid] = 3660 - [status] = 0 - [des] = + [tongxingimg] = 2016-08-15/57b19aaeb008c.png - [rutaiimg] = 2016-08-15/57b19aaeaf58e.png +)
See, find only finds a set of data in a data table, even if you don't give the Where condition;
Now look at the most used, the most changeable method of GetField;
Official Interpretation : "Reading a field value is actually getting multiple or single data from a column in a data table, the most common method is the getField
method" Note that theGetField must pass the name of the table field that needs to be queried , otherwise, The data being queried is empty, not all of the data
1 $customers=d (' customers '); 2 $customers _msg_all=$customers->where (' id=21 ')->getfield (' Mobile '); 3 Print_r ($customers _msg_all); die;
1 18826*****
Output a varchar data, not an array, can be used directly;
Use GetField to output a column value for a field in a data table:
$customers =d (' customers '); $customers _msg_all= $customers->getfield (' mobile '); Print_r ($customers _msg_all);d ie;
When you write like this, you still just output a phone number, that is, the database field mobile one of the values (the last one);
1 $customers=d (' customers '); 2 $customers _msg_all=$customers->getfield (' Mobile ',true); 3 Print_r ($customers _msg_all); die;
Output Result:
1 Array 2 (3 [0] = 1323**214 [1] = 188**605 [2] = 1890***198 6 )
So, Xiong said that the addition of true is to return a one-dimensional array, meaning to obtain a column of all values;
1 $customers=d (' customers '); 2 $customers _msg_all=$customers->getfield (' Mobile ', 2); 3 Print_r ($customers _msg_all); die;
Change true to 2, which means to take out the value of the column and limit the removal of 2 data:
1 Array 2 (3 [0] = = 1323**84 [1] = 1882***605 )
How many field names are passed in GetField???
1 $customers=d (' customers '); 2 $customers _msg_all=$customers
3 Print_r ($customers _msg_all); die;
Output:
1 Array 2 (3 [18826**60] = name14 [1323***9621] = name25 [189***9198] = Name36 )
Other incoming 3 or more database fields, the function and select overlap, there is less use, do not do a demonstration;
In general, query the entire table of data with select;
Query a row of data in a table with find;
Query the table of a column of data or a certain data with GetField;
GetField, Find, select, return data types in thinkphp (all data read in thinkphp)