2016-12-30 06:21:17 +01:00
|
|
|
<?php
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
namespace Amp\Postgres;
|
|
|
|
|
2018-07-01 19:33:12 +02:00
|
|
|
use Amp\Sql\CommandResult;
|
|
|
|
|
|
|
|
final class PgSqlCommandResult implements CommandResult
|
|
|
|
{
|
2016-09-14 16:27:39 +02:00
|
|
|
/** @var resource PostgreSQL result resource. */
|
|
|
|
private $handle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param resource $handle PostgreSQL result resource.
|
|
|
|
*/
|
2018-07-01 19:33:12 +02:00
|
|
|
public function __construct($handle)
|
|
|
|
{
|
2016-09-14 16:27:39 +02:00
|
|
|
$this->handle = $handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees the result resource.
|
|
|
|
*/
|
2018-07-01 19:33:12 +02:00
|
|
|
public function __destruct()
|
|
|
|
{
|
2016-09-14 16:27:39 +02:00
|
|
|
\pg_free_result($this->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int Number of rows affected by the INSERT, UPDATE, or DELETE query.
|
|
|
|
*/
|
2018-09-26 16:26:49 +02:00
|
|
|
public function getAffectedRowCount(): int
|
2018-07-01 19:33:12 +02:00
|
|
|
{
|
2016-09-14 16:27:39 +02:00
|
|
|
return \pg_affected_rows($this->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-09-26 16:26:49 +02:00
|
|
|
public function getLastOid(): string
|
2018-07-01 19:33:12 +02:00
|
|
|
{
|
2016-09-14 16:27:39 +02:00
|
|
|
return (string) \pg_last_oid($this->handle);
|
|
|
|
}
|
2017-02-16 06:33:41 +01:00
|
|
|
}
|