gpt4 book ai didi

php - 是否可以在 Laravel 迁移中使用 sql 查询

转载 作者:行者123 更新时间:2023-12-05 04:05:08 24 4
gpt4 key购买 nike

我有一个创建表查询,如下所示

> CREATE TABLE ep_student (
> student_id BIGSERIAL NOT NULL,
> stud_name CHARACTER(150) NOT NULL,
> no_kp CHARACTER(14) NOT NULL,
> dob DATE,
> birth_place CHARACTER(100),
> pob_desc CHARACTER(100),
> dt_enroll DATE,
> enroll_darjah CHARACTER(20),
> religion_id CHARACTER(10),
> ethnic_id CHARACTER(10),
> citizenship_id CHARACTER(10),
> warga_desc CHARACTER(100),
> gender_id CHARACTER(10),
> autisma_flag CHARACTER(10),
> lelah_flag CHARACTER(10),
> heart_flag CHARACTER(10),
> skin_flag CHARACTER(10),
> allergy_flag CHARACTER(10),
> disability_flag CHARACTER(10),
> disease_desc CHARACTER(100),
> disability_desc CHARACTER(100),
> dt_leftschool DATE,
> reason_leftschool CHARACTER(100),
> school_id BIGINT NOT NULL,
> birth_cert CHARACTER(20),
> CONSTRAINT PK_ep_student PRIMARY KEY (student_id, no_kp, school_id)

我可以在 Laravel 迁移文件中使用 DB::create 并将方案粘贴到其中吗?

最佳答案

要执行迁移查询,您可以使用 DB 类的 statement() 方法。

DB::statement("
CREATE TABLE `your_table` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`status` tinyint(3) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");

祝你好运

关于php - 是否可以在 Laravel 迁移中使用 sql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51510307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com