more 2.0 changes
This commit is contained in:
27
laravel/db/query/factory.php
Normal file
27
laravel/db/query/factory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php namespace Laravel\DB\Query;
|
||||
|
||||
use Laravel\DB\Query;
|
||||
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)
|
||||
{
|
||||
switch ($connection->driver())
|
||||
{
|
||||
case 'postgres':
|
||||
return new Postgres($table, $connection);
|
||||
|
||||
default:
|
||||
return new Query($table, $connection);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
24
laravel/db/query/postgres.php
Normal file
24
laravel/db/query/postgres.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php namespace Laravel\DB\Query;
|
||||
|
||||
use Laravel\DB\Query;
|
||||
|
||||
class Postgres extends Query {
|
||||
|
||||
/**
|
||||
* Execute an INSERT statement and get the insert ID.
|
||||
*
|
||||
* @param array $values
|
||||
* @return int
|
||||
*/
|
||||
public function insert_get_id($values)
|
||||
{
|
||||
$sql = $this->compile_insert($values);
|
||||
|
||||
$query = $this->connection->pdo->prepare($sql.' RETURNING '.$this->wrap('id'));
|
||||
|
||||
$query->execute(array_values($values));
|
||||
|
||||
return $query->fetch(\PDO::FETCH_CLASS, 'stdClass')->id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user