refactoring for dependency injection and testability.
This commit is contained in:
27
laravel/database/query/postgres.php
Normal file
27
laravel/database/query/postgres.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php namespace Laravel\Database\Query;
|
||||
|
||||
use Laravel\Database\Query;
|
||||
|
||||
class Postgres extends Query {
|
||||
|
||||
/**
|
||||
* Insert an array of values into the database table and return the value of the ID column.
|
||||
*
|
||||
* <code>
|
||||
* // Insert into the "users" table and get the auto-incrementing ID
|
||||
* $id = DB::table('users')->insert_get_id(array('email' => 'example@gmail.com'));
|
||||
* </code>
|
||||
*
|
||||
* @param array $values
|
||||
* @return int
|
||||
*/
|
||||
public function insert_get_id($values)
|
||||
{
|
||||
$query = $this->connection->pdo->prepare($this->compiler->insert_get_id($this, $values));
|
||||
|
||||
$query->execute(array_values($values));
|
||||
|
||||
return (int) $query->fetch(\PDO::FETCH_CLASS, 'stdClass')->id;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user