之前做得一个小项目代码
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());
}
}
}
这里调用D方法的数据表 前缀_Login 是不存在的,
今天再重新做一个新的项目的时候提醒出现这个,提示数据表不存在
求解,忘了当时是搞了TP得配置还是怎么的
模型对对应的数据表 默认是跟模型名同名的数据表
Login模型默认对应Login表,
如果不想这样对应,可以用
protected $tableName='tablename';
指定数据表名