Files
spa-api/laravel/database/query/postgres.php

27 lines
684 B
PHP
Raw Normal View History

<?php namespace Laravel\Database\Query;
2011-08-19 20:12:39 -05:00
use Laravel\Database\Query;
2011-08-19 20:12:39 -05:00
class Postgres extends Query {
/**
2011-08-22 21:56:42 -05:00
* 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>
2011-08-19 20:12:39 -05:00
*
* @param array $values
* @return int
*/
public function insert_get_id($values)
{
2011-08-22 21:56:42 -05:00
$query = $this->connection->pdo->prepare($this->compiler->insert_get_id($this, $values));
2011-08-19 20:12:39 -05:00
$query->execute(array_values($values));
2011-08-22 21:56:42 -05:00
return (int) $query->fetch(\PDO::FETCH_CLASS, 'stdClass')->id;
2011-08-19 20:12:39 -05:00
}
}