执行完php artisan db:seed我发现数据库里毛的没有后来发现 这是因为填充比迁移多一个步骤,我发现database/seeds目录下还有个DatabaseSeeder.php文件,他默认就存在不是我创建的打开它里面也有个run方法并且里面有一行代码注释掉了// $this->call(UsersTableSeeder::class);翻看了官方文档才知道db:seed命令会去运行...
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Hod extends Model { use HasFactory; protected $table = 'hods'; protected $primaryKey = 'id'; protected $fillable = 'user_id'; } 下面是我希望在控制器中执行查询的方法的代码: public function cr...
# 新建表 create table book (id int(11), name...char(21)); create table reader (id int(11), name char(21), phone int(12)); # 显示所有表 show tables; # 插入数据...into book values(02, '魔兽争霸'); insert into book values(id) values(03); # 显示所有表 select * from book;...
1DB::table('users')->insert( 2 ['email' => 'john@example.com', 'votes' => 0] 3);Inserting Records Into A Table With An Auto-Incrementing IDIf the table has an auto-incrementing id, use insertGetId to insert a record and retrieve the id:...
//$data = $reader->all();//获取excel的第几张表 $reader = $reader->getSheet(0); //获取表中的数据 $data = $reader->toArray();$result = $this->create_table($tabl_name,$data); dd($result);//dd($data); });}return view('query.index'); ...
namespace App\Http\Controllers\ProjectModel\BusinessManage\Database;useApp\Http\Controllers\ProjectModel\Common\Database\EloBusinessBaseDatabase;//父类classTbCategory2InfoextendsEloBusinessBaseDatabase {//表名protected$table= "tb_category2";//主键名protected$primaryKey= "id";//主键是自增idpublic$inc...
Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.Before getting started, be sure to configure a database connection in config/database.php. For more...
INSERT INTO `article` VALUES (2, '初识路由', 1); # 创建关键词表 CREATE TABLE `keyword` ( `id` INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, `keyword` VARCHAR(255) NOT NULL COMMENT '关键词' ) DEFAULT CHARSET=utf8mb4; # 创建中间表,保存文章和关键词的关联 CREATE TABLE `article_keyword` (...
DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']); 虽然DB门面指向的是Illuminate\Database\DatabaseManager的实例,但是对数据库交互上的操作,都会转发到connection上去执行。 回头看本文中Eloquent的生命周期关于DatabaseServiceProvider的启动方法的描述,DatabaseServiceProvider的启动方法...
'/' . $filename, $contents); // or... DB::table('hls_secrets')->insert([ 'video_id' => $videoId, 'filename' => $filename, 'contents' => $contents, ]); }) ->addFormat($lowBitrate) ->addFormat($midBitrate) ->addFormat($highBitrate) ->save('adaptive_steve.m3u8');...