Home > Article > Backend Development > php day-10 instantiation of data tables and classes
1.Instantiate an operation class of a database table
$user=new Model("User"); (Equivalent M method)
//"User" It is database table name. If there is a prefix, there is no need to add it. You can also write it like this
$list=$user->select();
2. When instantiating a database table, instantiate a custom model class at the same time, such as:
$user=new Model( "User","CommonModel");//CommonModel is a custom model class in the lib/model directory.
$list=$user->select();
var_dump($list);
$user->test();//The test method is a method defined in the custom model class CommonModel. Generally used as public models in this manner.
3.
Instantiate a custom model class: (D method?)
4.
Instantiate an empty database operation class for use in detailed database operation statements.
The above introduces the instantiation of php day-10 data tables and classes, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.