我试图用laravel代码创建一个临时表,插入值并在前端打印一些东西。但是我的临时表没有创建。
$temEmployee = DB::insert(DB::raw("CREATE TEMPORARY TABLE IF NOT EXISTS tmpEmp(
tmpid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
NIC varchar(100),
Designation varchar(100),
WorkPlace varchar(100),
Initials varchar(100),
LastName varchar(100),
DOB DATE,
Mobile varchar(10),
FirstAppoinment DATE,
DutyAssumeDate DATE
)"));
我的代码有问题吗?
1条答案
按热度按时间cgvd09ve1#
使用
DB::statement();
而不是DB::insert();
执行create table query
```$temEmployee = DB::statement("CREATE TEMPORARY TABLE IF NOT EXISTS tmpEmp(
tmpid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
NIC varchar(100),
Designation varchar(100),
WorkPlace varchar(100),
Initials varchar(100),
LastName varchar(100),
DOB DATE,
Mobile varchar(10),
FirstAppoinment DATE,
DutyAssumeDate DATE
)");