php day-10 instantiation of data tables and classes

WBOY
Release: 2016-08-08 09:27:40
Original
1593 people have browsed it

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();

var_dump($list);

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?)

$user=new UserModel ();//No need to pass The parameter table, because the model itself has given parameters, is user. This method is generally used when it is used as a single model function.

4.

Instantiate an empty database operation class for use in detailed database operation statements.

$user=new Model();

$list1=$user->query("select * from db_user");//If the database table has a prefix, A prefix must be added here, such as the db prefix here.

$list2=$user->query("select * from db_id");

var_dump($list1);

var_dump( $list2);

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template