Do ordinary PHP project to thinkphp, the field automatically complete match, Ajax when the foreground data is not available, after the discovery is the select and find return data sets are different, refer to the following method modification.
$this->ajaxreturn ($msg [0]); Select returns a two-dimensional array, and find returns a one-dimensional array.
Thinkphp is a good PHP development framework, can be more rapid development of the MVC architecture Management System, we need to use the Select () and the Find () method, two methods can return the array of datasets, but what is the difference? Let's take a look at my code comparison:
[PHP]View Plaincopy print?
- $tech =m (' techlevel ',' Hr_cs_ ',' db_config2 ');
- $Data =$tech->where (' id=1 ')->find ();
- Dump ($Data);
- $Data =$tech->where (' id=1 ')->select ();
- Dump ($Data);
$tech =m (' techlevel ', ' Hr_cs_ ', ' db_config2 '); $Data = $tech->where (' id=1 ')->find ();d UMP ($Data); $Data = $tech- >where (' id=1 ')->select ();d UMP ($Data);
Results
[PHP]View Plaincopy print?
- Array (6) {
- ["ID"] = + int (1)
- ["techlevel"] = + string (2) "Ten"
- ["Remark"] = + string (4) "??"
- ["createdate"] = + string (+) "2013-03-14 15:14:38"
- ["CreateBy"] = + string (5) "admin"
- ["row_number"] = + string (1) "1"
- }
- Array (1) {
- [0] = = Array (6) {
- ["ID"] = + int (1)
- ["techlevel"] = + string (2) "Ten"
- ["Remark"] = + string (4) "??"
- ["createdate"] = + string (+) "2013-03-14 15:14:38"
- ["CreateBy"] = + string (5) "admin"
- ["row_number"] = + string (1) "1"
- }
- }
Array (6) { ["ID"] = + int (1) ["techlevel"] = + string (2) "Ten" ["Remark"] + string (4) "??" ["createdate"] = + string (+) "2013-03-14 15:14:38" ["CreateBy"] + string (5) "admin" ["row_number"] = > string (1) "1"}array (1) { [0] = = Array (6) { ["ID"] = = Int (1) ["Techlevel"] + string (2) "Ten"
["Remark"] + string (4) "??" ["createdate"] = + string (+) "2013-03-14 15:14:38" ["CreateBy"] + string (5) "admin" ["row_number"] = > string (1) "1"} }
As can be seen from the above code, find () returns a one-dimensional array, select () returns a two-dimensional array, so when the value is different, one-dimensional array value with $data["Techlevel", the two-dimensional array value with $data[0]["Techlevel"], because at first did not understand this usage, debugging day is not worth, finally have the dump method to see the difference of two methods!
thinkphp the difference between Select and find (RPM)