When we use thinkphp development, we sometimes use GetByID (' 1 ') method to quickly get a message content, this method is more useful than using where ("ID =1")->find (), and query efficiency is faster than find.
Many people, when they first approached this method, did not pay much attention to its internal implementation mechanism, only to think that the information was obtained by ID, and that is not the case.
For example, some systems have Getbytitle ("Nihao"), Getbymoney (' 1000 ') methods, which are similar to the GetByID (' 1 ') just mentioned, and also implement the same functional principle as GetByID (' 1 ').
In fact, like this GetByID ($id), Getbytitle ($title), Getbyusername ($username), and so on, the "getby+ field" method has a proper noun called "magic Method", The field behind it can be any field in the data table, and the result can only be the first data that is queried , and this method is very efficient and well remembered.
Sometimes our field is not connected, for example: user_name such as the field, we do not write this way (Getbyuser_name ($name))? The answer is no, thinkphp does not support such a method, we need to use the Hump method to name , should be written so Getbyusername ($name) on it!
http://www.bkjia.com/PHPjc/824803.html www.bkjia.com true http://www.bkjia.com/PHPjc/824803.html techarticle when we use thinkphp development, we sometimes use the GetByID (' 1 ') method to quickly get a message content, this method is more useful than using the WHERE ("ID =1")-find (), at the same time ...