Create Action class [php] <? Php class NewObjectAction extends Action {public function index () {// 1. create a basic Model // 1: instantiate the database operation class of a system // new Model ('user') is equivalent to M ('user '), put a table to be operated in the Model /// 1 Name: //// thinkphp Default table name prefix, if it is think_user; you can use the User or user in the Model to obtain the // if it is think_user_message; then use Model ('usermessage '); in upper case, A _ // $ User = new Model ('user') is added before the table name '); //// call the query method // $ list = $ User-> select (); // dump ($ list); //// 2: Cross-model operations; instantiate a table and Instantiate a self-written database operation class // mostly used to extract some public business logic to form a public Model // M ('user', 'commonmodel ') equivalent to new CommonModel ('user'); model is automatically loaded // $ user = M ('user', 'commonmodel '); // $ user = new CommonModel ('user'); // $ list = $ user-> select (); // dump ($ list ); // $ user-> modelTest (); // 3: instantiate a user-defined model. // multiple models are used for businesses that do not need to be more complex. // 1. create a model manually and create a custom model for the user table. The function provided by thinkphp can be encapsulated. // $ user = new UserModel () is equivalent to D ('user '); // method D if the model does not exist, an exception is thrown and only one instance is used. By default, only calls are supported. Model under the current application // $ user = new UserModel (); // $ list = $ user-> select (); // dump ($ list ); // $ user-> modelTest (); // 4. instantiate an empty Model. It is a traditional SQL statement. You need to add the table prefix // $ user = new Model (); $ list = $ user-> query ('select * from tb_user '); dump ($ list); // group: D ('admin. user ') ;}}?> Two models: [php] <? Php class CommonModel extends Model {function modelTest () {echo 'test cross-Model operations, call the method in the Model ';}}?> [Php] <? Php class UserModel extends Model {function modelTest () {echo 'test cross-Model operations, call the method in the Model ';}}?>