factory.php 860 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php namespace Laravel\Database\Query\Compiler;
  2. use Laravel\Database\Connection;
  3. use Laravel\Database\Query\Compiler;
  4. class Factory {
  5. /**
  6. * Create a new query compiler for a given connection.
  7. *
  8. * Using driver-based compilers allows us to provide the proper syntax to different database
  9. * systems using a common API. A core set of functions is provided through the base Compiler
  10. * class, which can be extended and overridden for various database systems.
  11. *
  12. * @param Connection $connection
  13. * @return Compiler
  14. */
  15. public static function make(Connection $connection)
  16. {
  17. $compiler = (isset($connection->config['compiler'])) ? $connection->config['compiler'] : $connection->driver();
  18. switch ($compiler)
  19. {
  20. case 'mysql':
  21. return new MySQL;
  22. case 'pgsql':
  23. return new Postgres;
  24. default:
  25. return new Compiler;
  26. }
  27. }
  28. }