Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

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

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

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

#Laravel #Eloquent #DBMaker #PHP

mouson(墨嗓)

July 01, 2017
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

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 • [email protected] • 世成科技 系統分析師 • 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 source: https://zh.wikipedia.org/wiki/File:Spaghetti.jpg
  5. 墨墨嗓 (陳佑⽵竹) / 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
  6. 墨墨嗓 (陳佑⽵竹) / 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
  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 https://commons.wikimedia.org/w/index.php?curid=165211
  8. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Refactoring DBMaker Application

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

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

    Application Code DB Exec SQL Call Result Result Route Controller View Model ??? ???
  11. 墨墨嗓 (陳佑⽵竹) / 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
  12. 墨墨嗓 (陳佑⽵竹) / 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
  13. 墨墨嗓 (陳佑⽵竹) / 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
  14. 墨墨嗓 (陳佑⽵竹) / 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
  15. 墨墨嗓 (陳佑⽵竹) / 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
  16. 墨墨嗓 (陳佑⽵竹) / 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
  17. 墨墨嗓 (陳佑⽵竹) / 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
  18. 墨墨嗓 (陳佑⽵竹) / 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
  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 Database ServiceProvider \Illuminate\Database DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors 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 DatabaseManager \Illuminate\Database ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors 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 ConnectionFactory \Illuminate\Database\Connectors Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO 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 Connection \Illuminate\Database Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  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 Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  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 Connector \Illuminate\Database\Connectors PDO \PDO Config/database.php MySQL SQLServe SQLite
  25. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO provides a

    data- access abstraction MySQL SQLServer SQLite MySQL select `id`, `name` from `users`
  26. 墨墨嗓 (陳佑⽵竹) / 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); ...
  27. 墨墨嗓 (陳佑⽵竹) / 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); ...
  28. 墨墨嗓 (陳佑⽵竹) / 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); ...
  29. 墨墨嗓 (陳佑⽵竹) / 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); ...
  30. 墨墨嗓 (陳佑⽵竹) / 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); ...
  31. 墨墨嗓 (陳佑⽵竹) / 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); ...
  32. 墨墨嗓 (陳佑⽵竹) / 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 ?
  33. 墨墨嗓 (陳佑⽵竹) / 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
  34. 墨墨嗓 (陳佑⽵竹) / 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
  35. 墨墨嗓 (陳佑⽵竹) / 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
  36. 墨墨嗓 (陳佑⽵竹) / 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
  37. 墨墨嗓 (陳佑⽵竹) / 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();
  38. 墨墨嗓 (陳佑⽵竹) / 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();
  39. 墨墨嗓 (陳佑⽵竹) / 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();
  40. 墨墨嗓 (陳佑⽵竹) / 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
  41. 墨墨嗓 (陳佑⽵竹) / 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
  42. 墨墨嗓 (陳佑⽵竹) / 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
  43. 墨墨嗓 (陳佑⽵竹) / 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
  44. 墨墨嗓 (陳佑⽵竹) / 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
  45. 墨墨嗓 (陳佑⽵竹) / 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
  46. 墨墨嗓 (陳佑⽵竹) / 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
  47. 墨墨嗓 (陳佑⽵竹) / 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
  48. 墨墨嗓 (陳佑⽵竹) / 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
  49. 墨墨嗓 (陳佑⽵竹) / 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
  50. 墨墨嗓 (陳佑⽵竹) / 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
  51. 墨墨嗓 (陳佑⽵竹) / 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
  52. 墨墨嗓 (陳佑⽵竹) / 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
  53. 墨墨嗓 (陳佑⽵竹) / 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
  54. 墨墨嗓 (陳佑⽵竹) / 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
  55. 墨墨嗓 (陳佑⽵竹) / 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
  56. 墨墨嗓 (陳佑⽵竹) / 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
  57. 墨墨嗓 (陳佑⽵竹) / 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(); });
  58. 墨墨嗓 (陳佑⽵竹) / 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(); });
  59. 墨墨嗓 (陳佑⽵竹) / 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); })); }
  60. 墨墨嗓 (陳佑⽵竹) / 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); })); }
  61. 墨墨嗓 (陳佑⽵竹) / 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); })); }
  62. 墨墨嗓 (陳佑⽵竹) / 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); }
  63. 墨墨嗓 (陳佑⽵竹) / 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
  64. 墨墨嗓 (陳佑⽵竹) / 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); } }
  65. 墨墨嗓 (陳佑⽵竹) / 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
  66. 墨墨嗓 (陳佑⽵竹) / 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
  67. 墨墨嗓 (陳佑⽵竹) / 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
  68. 墨墨嗓 (陳佑⽵竹) / 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
  69. 墨墨嗓 (陳佑⽵竹) / 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
  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 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); }
  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 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); }
  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 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() ); }
  73. 墨墨嗓 (陳佑⽵竹) / 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); }
  74. 墨墨嗓 (陳佑⽵竹) / 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();
  75. 墨墨嗓 (陳佑⽵竹) / 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();
  76. 墨墨嗓 (陳佑⽵竹) / 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() ); ...略略...
  77. 墨墨嗓 (陳佑⽵竹) / 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();
  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 protected function runSelect() { return $this->connection->select( $this->toSql(), $this->getBindings(), !$this->useWritePdo ); }
  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 public function toSql() { return $this->grammar ->compileSelect($this); } DB::table('users') ->select('id', 'name') ->get();
  80. 墨墨嗓 (陳佑⽵竹) / 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 ); }
  81. 墨墨嗓 (陳佑⽵竹) / 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() ); ...略略...
  82. 墨墨嗓 (陳佑⽵竹) / 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 ??? ???
  83. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 PDO Support ?

    Source: http://php.net/manual/en/pdo.drivers.php
  84. 墨墨嗓 (陳佑⽵竹) / 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
  85. 墨墨嗓 (陳佑⽵竹) / 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
  86. 墨墨嗓 (陳佑⽵竹) / 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
  87. 墨墨嗓 (陳佑⽵竹) / 2017.07.01 LaravelConf Taiwan 2017 Tips • Data

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

    Type - Numeric/Char/Time/JSON • Auto Increment Support ? • Start From Unit Test
  89. 墨墨嗓 (陳佑⽵竹) / 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
  90. 墨墨嗓 (陳佑⽵竹) / 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
  91. 墨墨嗓 (陳佑⽵竹) / 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
  92. 墨墨嗓 (陳佑⽵竹) / 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
  93. 墨墨嗓 (陳佑⽵竹) / 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'; }
  94. 墨墨嗓 (陳佑⽵竹) / 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'; }
  95. 墨墨嗓 (陳佑⽵竹) / 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
  96. 墨墨嗓 (陳佑⽵竹) / 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'; }
  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 - Auto

    Increment Support MySQL auto_increment int auto_increment bigint auto_increment mediumint auto_increment smallint auto_increment tinyint
  99. 墨墨嗓 (陳佑⽵竹) / 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
  100. 墨墨嗓 (陳佑⽵竹) / 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
  101. 墨墨嗓 (陳佑⽵竹) / 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
  102. 墨墨嗓 (陳佑⽵竹) / 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'; } }
  103. 墨墨嗓 (陳佑⽵竹) / 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'; } }
  104. 墨墨嗓 (陳佑⽵竹) / 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'; } }
  105. 墨墨嗓 (陳佑⽵竹) / 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
  106. 墨墨嗓 (陳佑⽵竹) / 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'; }
  107. 墨墨嗓 (陳佑⽵竹) / 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'; } }
  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 Start from UnitTest

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

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

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

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

    !! •PHP 後端⼯工程師 •前端⼯工程師