The difference between thinkphp's Select and find

Source: Internet
Author: User
The difference between thinkphp's Select and find

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:

$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

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, a one-dimensional array value with $data["Techlevel"], two-dimensional array values with $data[0][" Techlevel "], because at first did not understand this usage, debugging a day is not worth, finally have the dump method to see the difference between two methods!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.