I'm trying to create a temporary table in the laravel code, insert values and print something on the front end. But my temporary table is not creating.
$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
)"));
Is there any issue with my code?
Use DB::statement();
instead of DB::insert();
to execute 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
)");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.