In TP, we can use the following two methods to create a mapping object of a data table (the one I use temporarily)
The first method: $Test = D('Test')
The second method: $Test = new Model ('Test')
Although both can perform select, insert, delete, and udpate operations on data, they are very different in data verification.
Let’s take a look at the effect. First create a TestModel
Copy Code The code is as follows:
class TestModel extends Model{
protected $_validate = array{
array('title','require','Please enter the title',1),
array('content','require ','Please enter content',1),
}
}
Copy code The code is as follows:
class TestAction extends Action{
public function Dtest(){
$test = D('Test'); //The first case
$test = new Model('Test'); //The second case
if($test->Create()){
$test-> ;Add();
}else{
$test->getError();
}
}
}
The above introduces the differences between the instance Model methods in thinkpad e40 0578a64 ThinkPHP, including the content of thinkpad e40 0578a64. I hope it will be helpful to friends who are interested in PHP tutorials.