2011-08-19 20:12:39 -05:00
|
|
|
<?php namespace Laravel\DB\Query;
|
|
|
|
|
|
|
|
|
|
use Laravel\DB\Query;
|
2011-08-19 22:09:17 -05:00
|
|
|
use Laravel\DB\Compiler;
|
2011-08-19 20:12:39 -05:00
|
|
|
use Laravel\DB\Connection;
|
|
|
|
|
|
|
|
|
|
class Factory {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new query instance for a given driver.
|
|
|
|
|
*
|
|
|
|
|
* @param string $table
|
|
|
|
|
* @param Connection $connection
|
|
|
|
|
* @return Query
|
|
|
|
|
*/
|
|
|
|
|
public static function make($table, Connection $connection)
|
|
|
|
|
{
|
2011-08-19 21:18:59 -05:00
|
|
|
$query = (isset($connection->config['query'])) ? $connection->config['query'] : $connection->driver();
|
|
|
|
|
|
|
|
|
|
switch ($query)
|
2011-08-19 20:12:39 -05:00
|
|
|
{
|
2011-08-19 21:18:59 -05:00
|
|
|
case 'pgsql':
|
2011-08-19 22:09:17 -05:00
|
|
|
return new Postgres($table, $connection, new Compiler);
|
2011-08-19 20:12:39 -05:00
|
|
|
|
2011-08-19 21:18:59 -05:00
|
|
|
case 'mysql':
|
2011-08-19 22:09:17 -05:00
|
|
|
return new MySQL($table, $connection, new Compiler);
|
2011-08-19 21:18:59 -05:00
|
|
|
|
2011-08-19 20:12:39 -05:00
|
|
|
default:
|
2011-08-19 22:09:17 -05:00
|
|
|
return new Query($table, $connection, new Compiler);
|
2011-08-19 20:12:39 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|