20170701 Eloquent 核心解構 讓 Laravel 支援更多資料庫

Ab628671841774343b1020f22f712069?s=47 mouson
July 01, 2017

20170701 Eloquent 核心解構 讓 Laravel 支援更多資料庫

LaravelConf Taiwan 2017
講師:墨嗓 (陳佑竹)

主要涵蓋範圍,介紹 Eloquent 的結構,以及如何讓 Eloquent 支援更多的資料庫。

簡報錄影:https://goo.gl/VQ9gbJ

#Laravel #Eloquent #DBMaker #PHP

Ab628671841774343b1020f22f712069?s=128

mouson

July 01, 2017
Tweet

Transcript

  1. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Eloquent 核⼼心解構 讓

    Laravel ⽀支援更更多資料庫 墨墨嗓 (陳佑⽵竹) 2017-07-01 LaravelConf Taiwan 2017
  2. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 墨墨嗓 (陳佑⽵竹) •

    @mouson • https://fb.me/mouson • https://github.com/mouson • mouson@gmail.com • 世成科技 系統分析師 • Laravel Taiwan、DevOps Taiwan 志⼯工 • Laravel 導入、系統規劃、分析、 重構 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017
  3. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 三不會⼀一只有 • 只有結構上的概念念介紹

    • 不會介紹有什什麼 Design Pattern • 不會做出⼀一個 Eloquent Driver • 不會 Live Coding
  4. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code
  5. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code source: https://zh.wikipedia.org/wiki/File:Spaghetti.jpg
  6. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code
  7. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code source: https://zh.wikipedia.org/wiki/File:Spaghetti.jpg https://zh.wikipedia.org/wiki/波动拳#/media/File:波动拳.gif
  8. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code source: https://zh.wikipedia.org/wiki/File:Spaghetti.jpg https://zh.wikipedia.org/wiki/波动拳#/media/File:波动拳.gif https://commons.wikimedia.org/w/index.php?curid=165211
  9. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Motivation DBMaker DB

    Exec SQL Result Application Code source: https://zh.wikipedia.org/wiki/File:Spaghetti.jpg https://zh.wikipedia.org/wiki/波动拳#/media/File:波动拳.gif https://commons.wikimedia.org/w/index.php?curid=165211
  10. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Debug

  11. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Debug Guy

  12. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 source: https://commons.wikimedia.org/wiki/File:豬八戒斬妖.jpg Debug

    Guy
  13. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Refactoring DBMaker Application

    Code DB Exec SQL Call Result Result Route Controller View Model
  14. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Refactoring DBMaker Laravel

    Application Code DB Exec SQL Call Result Result Route Controller View Model
  15. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Refactoring DBMaker Laravel

    Application Code DB Exec SQL Call Result Result Route Controller View Model ??? ???
  16. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Source: https://www.youtube.com/watch?v=rClNZLXSKA8

  17. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Structure MySQL SQLite

    PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  18. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Structure MySQL SQLite

    PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations DBMaker
  19. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Config/database.php
  20. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database Config/database.php
  21. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database Config/database.php
  22. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Config/database.php
  23. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Config/database.php
  24. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Config/database.php
  25. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors Config/database.php
  26. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors Config/database.php
  27. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php
  28. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  29. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  30. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  31. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 What is PDO

    ?
  32. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Source: http://php.net/manual/en/intro.pdo.php

  33. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite
  34. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users`
  35. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  36. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` MS SQLServer PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  37. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  38. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  39. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  40. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ...
  41. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLServer SQLite

    MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PHP Data Objects (PDO) $conn = new PDO(...) $conn->query($sql); ... "Standard" Query Lang ?
  42. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection Database

    ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  43. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection Database

    ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite Builder \Illuminate\Database\Query \Illuminate\Database\Schema MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  44. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection Database

    ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite Builder \Illuminate\Database\Query \Illuminate\Database\Schema MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  45. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Builder MySQL SQLServer

    SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PDO Builder
  46. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Builder MySQL SQLServer

    SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PDO Builder DB::table('users') ->select('id','name') ->get();
  47. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Builder MySQL SQLServer

    SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PDO Builder DB::table('users') ->select('id','name') ->get(); DB::table('users') ->select('id','name') ->get();
  48. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Builder MySQL SQLServer

    SQLite MySQL select `id`, `name` from `users` MS SQLServer select [id], [name] from [users] SQLite select "id", "name" from "users" PDO Builder DB::table('users') ->select('id','name') ->get();
  49. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection Database

    ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite Builder \Illuminate\Database\Query \Illuminate\Database\Schema MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  50. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Laravel Connection Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite Builder \Illuminate\Database\Query \Illuminate\Database\Schema Grammar \Illuminate\Database
  51. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations MySQL SQLite

    PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  52. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations MySQL SQLite

    PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  53. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  54. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Blueprint
  55. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Blueprint Builder
  56. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Blueprint Builder Grammar
  57. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Blueprint Builder Grammar Worker
  58. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Build a Building

    MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Blueprint Builder Grammar Building Worker
  59. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 class CreateUsersTable extends

    Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } Migrations MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  60. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 class CreateUsersTable extends

    Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } Schema Schema Schema Migration MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  61. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Schema Illuminate\Support\Facades

    MigrationServiceProvider DatabaseMigrationRepository Migrator MigrationCreator MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  62. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Schema Illuminate\Support\Facades

    public static function connection($name) { return static::$app['db']->connection($name) ->getSchemaBuilder(); } MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  63. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Schema Illuminate\Support\Facades

    Connection Illuminate\Database Builder Illuminate\Database\Schema DB public static function connection($name) { return static::$app['db']->connection($name) ->getSchemaBuilder(); } MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  64. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Schema Illuminate\Support\Facades

    Connection Illuminate\Database Builder Illuminate\Database\Schema DB MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  65. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 class CreateUsersTable extends

    Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } Blueprint Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  66. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); });
  67. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB public function create($table, Closure $callback) { $this->build(tap( $this->createBlueprint($table), function ($blueprint) use ($callback) { $blueprint->create(); $callback($blueprint); })); } Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); });
  68. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); public function create($table, Closure $callback) { $this->build(tap( $this->createBlueprint($table), function ($blueprint) use ($callback) { $blueprint->create(); $callback($blueprint); })); }
  69. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Blueprint Illuminate\Database\Schema Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); public function create($table, Closure $callback) { $this->build(tap( $this->createBlueprint($table), function ($blueprint) use ($callback) { $blueprint->create(); $callback($blueprint); })); }
  70. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Blueprint Illuminate\Database\Schema Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); public function create($table, Closure $callback) { $this->build(tap( $this->createBlueprint($table), function ($blueprint) use ($callback) { $blueprint->create(); $callback($blueprint); })); }
  71. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Blueprint Illuminate\Database\Schema Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); protected function build(Blueprint $blueprint) { $blueprint->build($this->connection, $this->grammar); }
  72. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema DB Blueprint Illuminate\Database\Schema Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); protected function build(Blueprint $blueprint) { $blueprint->build($this->connection, $this->grammar); } Grammar Illuminate\Database\Schema\Grammars
  73. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Migrations Grammar Illuminate\Database\Schema\Grammars Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Blueprint Illuminate\Database\Schema DB Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); public function build(Connection $connection, Grammar $grammar) { foreach ($this->toSql($connection, $grammar) as $statement) { $connection->statement($statement); } }
  74. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Grammar Illuminate\Database\Schema\Grammars

    Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Blueprint Illuminate\Database\Schema DB MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  75. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Migrations Grammar Illuminate\Database\Schema\Grammars

    Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Blueprint Illuminate\Database\Schema DB MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  76. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder MySQL SQLite

    PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  77. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 DB::table('users') ->select('id', 'name')

    ->get(); QueryBuilder MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  78. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  79. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); public function table($table) { return $this->query() ->from($table); }
  80. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); public function table($table) { return $this->query() ->from($table); }
  81. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); public function query() { return new QueryBuilder( $this, $this->getQueryGrammar(), $this->getPostProcessor() ); }
  82. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations public function table($table) { return $this->query() ->from($table); }
  83. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB public function select($columns = ['*']) { $this->columns = is_array($columns) ? $columns : func_get_args(); return $this; } DB::table('users') ->select('id', 'name') ->get();
  84. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB public function get($columns = ['*']) { $original = $this->columns; ...略略... $results = $this->processor ->processSelect( $this, $this->runSelect() ); ...略略... DB::table('users') ->select('id', 'name') ->get();
  85. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations public function get($columns = ['*']) { $original = $this->columns; ...略略... $results = $this->processor ->processSelect( $this, $this->runSelect() ); ...略略...
  86. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB protected function runSelect() { return $this->connection->select( $this->toSql(), $this->getBindings(), !$this->useWritePdo ); } DB::table('users') ->select('id', 'name') ->get();
  87. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations protected function runSelect() { return $this->connection->select( $this->toSql(), $this->getBindings(), !$this->useWritePdo ); }
  88. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite PostgreSQL

    SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations QueryBuilder Grammar Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB public function toSql() { return $this->grammar ->compileSelect($this); } DB::table('users') ->select('id', 'name') ->get();
  89. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations protected function runSelect() { return $this->connection->select( $this->toSql(), $this->getBindings(), !$this->useWritePdo ); }
  90. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 QueryBuilder Grammar Illuminate\Database\Schema\Grammars

    DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB DB::table('users') ->select('id', 'name') ->get(); MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations public function get($columns = ['*']) { $original = $this->columns; ...略略... $results = $this->processor ->processSelect( $this, $this->runSelect() ); ...略略...
  91. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 How To Create

    Own Driver ? MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations DBMaker ??? ???
  92. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO Support ?

    Source: http://php.net/manual/en/pdo.drivers.php
  93. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Connection MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite Builder \Illuminate\Database\Query \Illuminate\Database\Schema Grammar \Illuminate\Database
  94. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel Migrations MySQL

    SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations Grammar Illuminate\Database\Schema\Grammars Schema Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Blueprint Illuminate\Database\Schema DB
  95. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Laravel QueryBuilder Grammar

    Illuminate\Database\Schema\Grammars DB Illuminate\Support\Facades Connection Illuminate\Database Builder Illuminate\Database\Schema Processor Illuminate\Database\Schema\Processors DB MySQL SQLite PostgreSQL SQL Server Laravel Model Application Code DB Exec SQL Call Result Result Eloquent Model Query Builder DB Connection (PHP Data Objects) Migrations
  96. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017

  97. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips • Data

    Type - Numeric/Char/Time/JSON • Auto Increment Support ? • Start From Unit Test
  98. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips • Data

    Type - Numeric/Char/Time/JSON • Auto Increment Support ? • Start From Unit Test
  99. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer
  100. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL int 4 byte bigint 8 byte mediumint 3 byte smallint 2 byte tinyint 1 byte
  101. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL int 4 byte bigint 8 byte mediumint 3 byte smallint 2 byte tinyint 1 byte SQLite integer integer integer integer integer
  102. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL int 4 byte bigint 8 byte mediumint 3 byte smallint 2 byte tinyint 1 byte SQLite integer integer integer integer integer SQLServer int 4 byte bigint 8 byte smallint 2 byte tinyint 1 byte
  103. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL int 4 byte bigint 8 byte mediumint 3 byte smallint 2 byte tinyint 1 byte SQLite integer integer integer integer integer SQLServer int 4 byte bigint 8 byte smallint 2 byte tinyint 1 byte Postgres integer 4 byte bigint 8 byte smallint 2 byte
  104. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL SQLite SQLServer Postgres int 4 byte integer int 4 byte integer 4 byte bigint 8 byte integer bigint 8 byte bigint 8 byte mediumint 3 byte integer smallint 2 byte integer smallint 2 byte smallint 2 byte tinyint 1 byte integer tinyint 1 byte protected function typeMediumInteger(Fluent $column) { return 'mediumint'; }
  105. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL SQLite SQLServer Postgres int 4 byte integer int 4 byte integer 4 byte bigint 8 byte integer bigint 8 byte bigint 8 byte mediumint 3 byte integer smallint 2 byte integer smallint 2 byte smallint 2 byte tinyint 1 byte integer tinyint 1 byte protected function typeMediumInteger(Fluent $column) { return 'integer'; }
  106. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL SQLite SQLServer Postgres int 4 byte integer int 4 byte integer 4 byte bigint 8 byte integer bigint 8 byte bigint 8 byte mediumint 3 byte integer smallint 2 byte integer smallint 2 byte smallint 2 byte tinyint 1 byte integer tinyint 1 byte
  107. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Data

    Type - Integer MySQL SQLite SQLServer Postgres int 4 byte integer int 4 byte integer 4 byte bigint 8 byte integer bigint 8 byte bigint 8 byte mediumint 3 byte integer smallint 2 byte integer smallint 2 byte smallint 2 byte tinyint 1 byte integer tinyint 1 byte protected function typeMediumInteger(Fluent $column) { return 'int'; }
  108. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips • Data

    Type - Numeric/Char/Time/JSON • Auto Increment Support ? • Start From Unit Test
  109. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Auto

    Increment Support
  110. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Auto

    Increment Support MySQL auto_increment int auto_increment bigint auto_increment mediumint auto_increment smallint auto_increment tinyint
  111. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Auto

    Increment Support MySQL auto_increment int auto_increment bigint auto_increment mediumint auto_increment smallint auto_increment tinyint SQLite autoincrement integer autoincrement integer autoincrement integer autoincrement integer autoincrement integer
  112. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Auto

    Increment Support MySQL auto_increment int auto_increment bigint auto_increment mediumint auto_increment smallint auto_increment tinyint SQLite autoincrement integer autoincrement integer autoincrement integer autoincrement integer autoincrement integer SQLServer identity int identity bigint identity smallint identity tinyint
  113. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips - Auto

    Increment Support MySQL auto_increment int auto_increment bigint auto_increment mediumint auto_increment smallint auto_increment tinyint SQLite autoincrement integer autoincrement integer autoincrement integer autoincrement integer autoincrement integer SQLServer identity int identity bigint identity smallint identity tinyint Postgres serial 4 byte bigserial 8 byte smallserial 2 byte
  114. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support protected function modifyIncrement(Blueprint $blueprint, Fluent $column) { if (in_array($column->type, $this->serials) && $column->autoIncrement) { return ' auto_increment primary key'; } }
  115. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support protected function modifyIncrement(Blueprint $blueprint, Fluent $column) { if (in_array($column->type, $this->serials) && $column->autoIncrement) { return ' primary key autoincrement'; } }
  116. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support protected function modifyIncrement(Blueprint $blueprint, Fluent $column) { if (in_array($column->type, $this->serials) && $column->autoIncrement) { return ' identity primary key'; } }
  117. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support
  118. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support protected function typeMediumInteger(Fluent $column) { return $column->autoIncrement ? 'serial' : 'integer'; }
  119. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 MySQL SQLite SQLServer

    Postgres auto_increment int autoincrement integer identity int serial 4 byte auto_increment bigint autoincrement integer identity bigint bigserial 8 byte auto_increment mediumint autoincrement integer auto_increment smallint autoincrement integer identity smallint smallserial 2 byte auto_increment tinyint autoincrement integer identity tinyint Tips - Auto Increment Support protected function typeMediumInteger(Fluent $column) { return $column->autoIncrement ? 'serial' : 'integer'; } protected function modifyIncrement(Blueprint $blueprint, Fluent $column) { if (in_array($column->type, $this->serials) && $column->autoIncrement) { return ' primary key'; } }
  120. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips • Data

    Type - Numeric/Char/Time/JSON • Auto Increment Support ? • Start From Unit Test
  121. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Start from UnitTest

    https://github.com/whatthejeff/nyancat-phpunit-resultprinter
  122. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Start from UnitTest

    https://github.com/whatthejeff/nyancat-phpunit-resultprinter
  123. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Start from UnitTest

    https://github.com/whatthejeff/nyancat-phpunit-resultprinter
  124. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Summary • PDO

    Support ? • DataType • Grammar • Start from unit test
  125. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 WE WANT YOU

    !! •PHP 後端⼯工程師 •前端⼯工程師
  126. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017

  127. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Q&A