Before doing a small project code
class LoginController extends Controller { public function login(){ $Admin = D('Login'); //实例化Admin模型 if ($Admin->create()){ //创建数据模型 $user = I('post.name'); $this->session($user); $this->success('Login success!',"/hc_tp/Admin"); //跳转到内页面 }else { echo $this->error($Admin->getError()); } }}
The data table prefix _login of the D method is not present here,
When you re-make a new project today, remind me of this, the data sheet does not exist.
To solve, forget that it was a TP to configure or how
Reply content:
Before doing a small project code
class LoginController extends Controller { public function login(){ $Admin = D('Login'); //实例化Admin模型 if ($Admin->create()){ //创建数据模型 $user = I('post.name'); $this->session($user); $this->success('Login success!',"/hc_tp/Admin"); //跳转到内页面 }else { echo $this->error($Admin->getError()); } }}
The data table prefix _login of the D method is not present here,
When you re-make a new project today, remind me of this, the data sheet does not exist.
To solve, forget that it was a TP to configure or how
A data table with the same name as the model name is defaulted to the corresponding datasheet.
The login model corresponds to the login table by default,
If you do not want this to correspond, you can use
protected $tableName = ' tableName ';
Specify the data table name
Think the name of the model in PHP must be a table name
The internal implementation of the D method is the instantiation of the specific data table class
You can set up a virtual model
class LoginModel extends Model { protected $autoCkeckFields = false; //关闭检测字段}
Not necessarily! should be d (modelname); The default modelname corresponding to the table name, does not correspond to the words will be error, but you can pass
protected $autocheckfields = false; To turn off auto-correspondence so that you can do whatever m (any table name) in the model