Talking about the thinkphp model of the case
This article mainly introduces several methods of Thinkphp's instantiation model, and the use points between them, very good, recommend to everyone.
The thinkphp instantiation model gives us three ways to
The first is more commonly used
is the $user=new Model (' user '); Also equals $user =m (' user ')
The second is if we have a public model
That's what we use.
For example, we create a model CommonModel.class.php this public
This is what we instantiate.
The code is as follows:
$user =new commonmodel (' user ');
So that we can both instantiate the user model and invoke the method inside the public model
The third is for our instantiation model
Create a model UserModel.class.php
Instantiation is such a $user=new usermodel ();
So that's it, mostly our business logic is more when we use this
Fourth, why would there be a fourth model of emptiness?
The code is as follows:
$user = new Model (); Equivalent to $user=m ();
Then we'll use the SQL statement.
The code is as follows:
$list = $user->query (' select * from Wd_user ');
The use of the D method can automatically detect the model class when it does not exist, throws an exception, does not repeat the instantiation, can only support the current project or the instantiation of the application
Instantiate about that much, and continue to tell you about thinkphp things.
Summarize:
The model definition and instantiation introduced in this paper are biased to the theory, but in the later development, the operation of the data should use the model instantiation, according to the actual situation of the project, we can adopt different model instantiation methods.
http://www.bkjia.com/PHPjc/975900.html www.bkjia.com true http://www.bkjia.com/PHPjc/975900.html techarticle A brief talk on the thinkphp model in the paper this article mainly introduces several methods of thinkphp model, and the use points between them, very good, recommend to everyone. ...