class PostgresConnection extends Connection (View source)
| DetectsConcurrencyErrors | |
| DetectsLostConnections | |
| ManagesTransactions | |
| InteractsWithTime | |
| Macroable |
| static protected array | $macros | The registered string macros. | from Macroable |
| protected PDO|Closure | $pdo | The active PDO connection. | from Connection |
| protected PDO|Closure | $readPdo | The active PDO connection used for reads. | from Connection |
| protected string | $database | The name of the connected database. | from Connection |
| protected string|null | $readWriteType | The type of the connection. | from Connection |
| protected string | $tablePrefix | The table prefix for the connection. | from Connection |
| protected array | $config | The database connection configuration options. | from Connection |
| protected callable | $reconnector | The reconnector instance for the connection. | from Connection |
| protected Grammar | $queryGrammar | The query grammar implementation. | from Connection |
| protected Grammar | $schemaGrammar | The schema grammar implementation. | from Connection |
| protected Processor | $postProcessor | The query post processor implementation. | from Connection |
| protected Dispatcher | $events | The event dispatcher instance. | from Connection |
| protected int | $fetchMode | The default fetch mode of the connection. | from Connection |
| protected int | $transactions | The number of active transactions. | from Connection |
| protected DatabaseTransactionsManager | $transactionsManager | The transaction manager instance. | from Connection |
| protected bool | $recordsModified | Indicates if changes have been made to the database. | from Connection |
| protected bool | $readOnWriteConnection | Indicates if the connection should use the "write" PDO connection. | from Connection |
| protected array | $queryLog | All of the queries run against the connection. | from Connection |
| protected bool | $loggingQueries | Indicates whether queries are being logged. | from Connection |
| protected float | $totalQueryDuration | The duration of all executed queries in milliseconds. | from Connection |
| protected array | $queryDurationHandlers | All of the registered query duration handlers. | from Connection |
| protected bool | $pretending | Indicates if the connection is in a "dry run". | from Connection |
| protected Closure[] | $beforeStartingTransaction | All of the callbacks that should be invoked before a transaction is started. | from Connection |
| protected Closure[] | $beforeExecutingCallbacks | All of the callbacks that should be invoked before a query is executed. | from Connection |
| static protected Closure[] | $resolvers | The connection resolvers. | from Connection |
| bool | causedByConcurrencyError(Throwable $e)
Determine if the given exception was caused by a concurrency error such as a deadlock or serialization failure. | from DetectsConcurrencyErrors |
| bool | causedByLostConnection(Throwable $e)
Determine if the given exception was caused by a lost connection. | from DetectsLostConnections |
| mixed | transaction(Closure $callback, int $attempts = 1)
Execute a Closure within a transaction. | from ManagesTransactions |
| void | handleTransactionException(Throwable $e, int $currentAttempt, int $maxAttempts)
Handle an exception encountered when running a transacted statement. | from ManagesTransactions |
| void | beginTransaction()
Start a new database transaction. | from ManagesTransactions |
| void | createTransaction()
Create a transaction within the database. | from ManagesTransactions |
| void | createSavepoint()
Create a save point within the database. | from ManagesTransactions |
| void | handleBeginTransactionException(Throwable $e)
Handle an exception from a transaction beginning. | from ManagesTransactions |
| void | commit()
Commit the active database transaction. | from ManagesTransactions |
| void | handleCommitTransactionException(Throwable $e, int $currentAttempt, int $maxAttempts)
Handle an exception encountered when committing a transaction. | from ManagesTransactions |
| void | rollBack(int|null $toLevel = null)
Rollback the active database transaction. | from ManagesTransactions |
| void | performRollBack(int $toLevel)
Perform a rollback within the database. | from ManagesTransactions |
| void | handleRollBackException(Throwable $e)
Handle an exception from a rollback. | from ManagesTransactions |
| int | transactionLevel()
Get the number of active transactions. | from ManagesTransactions |
| void | afterCommit(callable $callback)
Execute the callback after a transaction commits. | from ManagesTransactions |
| int | secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime. | from InteractsWithTime |
| int | availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp. | from InteractsWithTime |
| DateTimeInterface|int | parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance. | from InteractsWithTime |
| int | currentTime()
Get the current system time as a UNIX timestamp. | from InteractsWithTime |
| string | runTimeForHumans(float $startTime, float $endTime = null)
Given a start time, format the total run time for human readability. | from InteractsWithTime |
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| void | __construct(PDO|Closure $pdo, string $database = '', string $tablePrefix = '', array $config = [])
Create a new database connection instance. | from Connection |
| void | useDefaultQueryGrammar()
Set the query grammar to the default implementation. | from Connection |
| Grammar | getDefaultQueryGrammar()
Get the default query grammar instance. | |
| void | useDefaultSchemaGrammar()
Set the schema grammar to the default implementation. | from Connection |
| Grammar|null | getDefaultSchemaGrammar()
Get the default schema grammar instance. | |
| void | useDefaultPostProcessor()
Set the query post processor to the default implementation. | from Connection |
| Processor | getDefaultPostProcessor()
Get the default post processor instance. | |
| Builder | getSchemaBuilder()
Get a schema builder instance for the connection. | |
| Builder | table(Closure|Builder|string $table, string|null $as = null)
Begin a fluent query against a database table. | from Connection |
| Builder | query()
Get a new query builder instance. | from Connection |
| mixed | selectOne(string $query, array $bindings = [], bool $useReadPdo = true)
Run a select statement and return a single result. | from Connection |
| mixed | scalar(string $query, array $bindings = [], bool $useReadPdo = true)
Run a select statement and return the first column of the first row. | from Connection |
| array | selectFromWriteConnection(string $query, array $bindings = [])
Run a select statement against the database. | from Connection |
| array | select(string $query, array $bindings = [], bool $useReadPdo = true)
Run a select statement against the database. | from Connection |
| array | selectResultSets(string $query, array $bindings = [], bool $useReadPdo = true)
Run a select statement against the database and returns all of the result sets. | from Connection |
| Generator | cursor(string $query, array $bindings = [], bool $useReadPdo = true)
Run a select statement against the database and returns a generator. | from Connection |
| PDOStatement | prepared(PDOStatement $statement)
Configure the PDO prepared statement. | from Connection |
| PDO | getPdoForSelect(bool $useReadPdo = true)
Get the PDO connection to use for a select query. | from Connection |
| bool | insert(string $query, array $bindings = [])
Run an insert statement against the database. | from Connection |
| int | update(string $query, array $bindings = [])
Run an update statement against the database. | from Connection |
| int | delete(string $query, array $bindings = [])
Run a delete statement against the database. | from Connection |
| bool | statement(string $query, array $bindings = [])
Execute an SQL statement and return the boolean result. | from Connection |
| int | affectingStatement(string $query, array $bindings = [])
Run an SQL statement and get the number of rows affected. | from Connection |
| bool | unprepared(string $query)
Run a raw, unprepared query against the PDO connection. | from Connection |
| array | pretend(Closure $callback)
Execute the given callback in "dry run" mode. | from Connection |
| mixed | withoutPretending(Closure $callback)
Execute the given callback without "pretending". | from Connection |
| array | withFreshQueryLog(Closure $callback)
Execute the given callback in "dry run" mode. | from Connection |
| void | bindValues(PDOStatement $statement, array $bindings)
Bind values to their parameters in the given statement. | from Connection |
| array | prepareBindings(array $bindings)
Prepare the query bindings for execution. | from Connection |
| mixed | run(string $query, array $bindings, Closure $callback)
Run a SQL statement and log its execution context. | from Connection |
| mixed | runQueryCallback(string $query, array $bindings, Closure $callback)
Run a SQL statement. | from Connection |
| bool | isUniqueConstraintError(Exception $exception)
Determine if the given database exception was caused by a unique constraint violation. | |
| void | logQuery(string $query, array $bindings, float|null $time = null)
Log a query in the connection's query log. | from Connection |
| float | getElapsedTime(int $start)
Get the elapsed time since a given starting point. | from Connection |
| void | whenQueryingForLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)
Register a callback to be invoked when the connection queries for longer than a given amount of time. | from Connection |
| void | allowQueryDurationHandlersToRunAgain()
Allow all the query duration handlers to run again, even if they have already run. | from Connection |
| float | totalQueryDuration()
Get the duration of all run queries in milliseconds. | from Connection |
| void | resetTotalQueryDuration()
Reset the duration of all run queries. | from Connection |
| mixed | handleQueryException(QueryException $e, string $query, array $bindings, Closure $callback)
Handle a query exception. | from Connection |
| mixed | tryAgainIfCausedByLostConnection(QueryException $e, string $query, array $bindings, Closure $callback)
Handle a query exception that occurred during query execution. | from Connection |
| mixed|false | reconnect()
Reconnect to the database. | from Connection |
| void | reconnectIfMissingConnection()
Reconnect to the database if a PDO connection is missing. | from Connection |
| void | disconnect()
Disconnect from the underlying PDO connection. | from Connection |
| $this | beforeStartingTransaction(Closure $callback)
Register a hook to be run just before a database transaction is started. | from Connection |
| $this | beforeExecuting(Closure $callback)
Register a hook to be run just before a database query is executed. | from Connection |
| void | listen(Closure $callback)
Register a database query listener with the connection. | from Connection |
| array|null | fireConnectionEvent(string $event)
Fire an event for this connection. | from Connection |
| void | event(mixed $event)
Fire the given event if possible. | from Connection |
| Expression | raw(mixed $value)
Get a new raw query expression. | from Connection |
| string | escape(string|float|int|bool|null $value, bool $binary = false)
Escape a value for safe SQL embedding. | from Connection |
| string | escapeString(string $value)
Escape a string value for safe SQL embedding. | from Connection |
| string | escapeBool(bool $value)
Escape a bool value for safe SQL embedding. | |
| string | escapeBinary(string $value)
Escape a binary value for safe SQL embedding. | |
| bool | hasModifiedRecords()
Determine if the database connection has modified any database records. | from Connection |
| void | recordsHaveBeenModified(bool $value = true)
Indicate if any records have been modified. | from Connection |
| $this | setRecordModificationState(bool $value)
Set the record modification state. | from Connection |
| void | forgetRecordModificationState()
Reset the record modification state. | from Connection |
| $this | useWriteConnectionWhenReading(bool $value = true)
Indicate that the connection should use the write PDO connection for reads. | from Connection |
| PDO | getPdo()
Get the current PDO connection. | from Connection |
| PDO|Closure|null | getRawPdo()
Get the current PDO connection parameter without executing any reconnect logic. | from Connection |
| PDO | getReadPdo()
Get the current PDO connection used for reading. | from Connection |
| PDO|Closure|null | getRawReadPdo()
Get the current read PDO connection parameter without executing any reconnect logic. | from Connection |
| $this | setPdo(PDO|Closure|null $pdo)
Set the PDO connection. | from Connection |
| $this | setReadPdo(PDO|Closure|null $pdo)
Set the PDO connection used for reading. | from Connection |
| $this | setReconnector(callable $reconnector)
Set the reconnect instance on the connection. | from Connection |
| string|null | getName()
Get the database connection name. | from Connection |
| string|null | getNameWithReadWriteType()
Get the database connection full name. | from Connection |
| mixed | getConfig(string|null $option = null)
Get an option from the configuration options. | from Connection |
| string | getDriverName()
Get the PDO driver name. | from Connection |
| Grammar | getQueryGrammar()
Get the query grammar used by the connection. | from Connection |
| $this | setQueryGrammar(Grammar $grammar)
Set the query grammar used by the connection. | from Connection |
| Grammar | getSchemaGrammar()
Get the schema grammar used by the connection. | from Connection |
| $this | setSchemaGrammar(Grammar $grammar)
Set the schema grammar used by the connection. | from Connection |
| Processor | getPostProcessor()
Get the query post processor used by the connection. | from Connection |
| $this | setPostProcessor(Processor $processor)
Set the query post processor used by the connection. | from Connection |
| Dispatcher | getEventDispatcher()
Get the event dispatcher used by the connection. | from Connection |
| $this | setEventDispatcher(Dispatcher $events)
Set the event dispatcher instance on the connection. | from Connection |
| void | unsetEventDispatcher()
Unset the event dispatcher for this connection. | from Connection |
| $this | setTransactionManager(DatabaseTransactionsManager $manager)
Set the transaction manager instance on the connection. | from Connection |
| void | unsetTransactionManager()
Unset the transaction manager for this connection. | from Connection |
| bool | pretending()
Determine if the connection is in a "dry run". | from Connection |
| array | getQueryLog()
Get the connection query log. | from Connection |
| array | getRawQueryLog()
Get the connection query log with embedded bindings. | from Connection |
| void | flushQueryLog()
Clear the query log. | from Connection |
| void | enableQueryLog()
Enable the query log on the connection. | from Connection |
| void | disableQueryLog()
Disable the query log on the connection. | from Connection |
| bool | logging()
Determine whether we're logging queries. | from Connection |
| string | getDatabaseName()
Get the name of the connected database. | from Connection |
| $this | setDatabaseName(string $database)
Set the name of the connected database. | from Connection |
| $this | setReadWriteType(string|null $readWriteType)
Set the read / write type of the connection. | from Connection |
| string | getTablePrefix()
Get the table prefix for the connection. | from Connection |
| $this | setTablePrefix(string $prefix)
Set the table prefix in use by the connection. | from Connection |
| Grammar | withTablePrefix(Grammar $grammar)
Set the table prefix and return the grammar. | from Connection |
| string | getServerVersion()
Get the server version for the connection. | from Connection |
| static void | resolverFor(string $driver, Closure $callback)
Register a connection resolver. | from Connection |
| static mixed | getResolver(string $driver)
Get the connection resolver for the given driver. | from Connection |
| PostgresSchemaState | getSchemaState(Filesystem|null $files = null, callable|null $processFactory = null)
Get the schema state for the connection. |
Determine if the given exception was caused by a concurrency error such as a deadlock or serialization failure.
Determine if the given exception was caused by a lost connection.
Execute a Closure within a transaction.
Handle an exception encountered when running a transacted statement.
Start a new database transaction.
Create a transaction within the database.
Create a save point within the database.
Handle an exception from a transaction beginning.
Commit the active database transaction.
Handle an exception encountered when committing a transaction.
Rollback the active database transaction.
Perform a rollback within the database.
Handle an exception from a rollback.
Get the number of active transactions.
Execute the callback after a transaction commits.
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Get the current system time as a UNIX timestamp.
Given a start time, format the total run time for human readability.
Register a custom macro.
Mix another object into the class.
Checks if macro is registered.
Flush the existing macros.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new database connection instance.
Set the query grammar to the default implementation.
Get the default query grammar instance.
Set the schema grammar to the default implementation.
Get the default schema grammar instance.
Set the query post processor to the default implementation.
Get the default post processor instance.
Get a schema builder instance for the connection.
Begin a fluent query against a database table.
Get a new query builder instance.
Run a select statement and return a single result.
Run a select statement and return the first column of the first row.
Run a select statement against the database.
Run a select statement against the database.
Run a select statement against the database and returns all of the result sets.
Run a select statement against the database and returns a generator.
Configure the PDO prepared statement.
Get the PDO connection to use for a select query.
Run an insert statement against the database.
Run an update statement against the database.
Run a delete statement against the database.
Execute an SQL statement and return the boolean result.
Run an SQL statement and get the number of rows affected.
Run a raw, unprepared query against the PDO connection.
Execute the given callback in "dry run" mode.
Execute the given callback without "pretending".
Execute the given callback in "dry run" mode.
Bind values to their parameters in the given statement.
Prepare the query bindings for execution.
Run a SQL statement and log its execution context.
Run a SQL statement.
Determine if the given database exception was caused by a unique constraint violation.
Log a query in the connection's query log.
Get the elapsed time since a given starting point.
Register a callback to be invoked when the connection queries for longer than a given amount of time.
Allow all the query duration handlers to run again, even if they have already run.
Get the duration of all run queries in milliseconds.
Reset the duration of all run queries.
Handle a query exception.
Handle a query exception that occurred during query execution.
Reconnect to the database.
Reconnect to the database if a PDO connection is missing.
Disconnect from the underlying PDO connection.
Register a hook to be run just before a database transaction is started.
Register a hook to be run just before a database query is executed.
Register a database query listener with the connection.
Fire an event for this connection.
Fire the given event if possible.
Get a new raw query expression.
Escape a value for safe SQL embedding.
Escape a string value for safe SQL embedding.
Escape a bool value for safe SQL embedding.
Escape a binary value for safe SQL embedding.
Determine if the database connection has modified any database records.
Indicate if any records have been modified.
Set the record modification state.
Reset the record modification state.
Indicate that the connection should use the write PDO connection for reads.
Get the current PDO connection.
Get the current PDO connection parameter without executing any reconnect logic.
Get the current PDO connection used for reading.
Get the current read PDO connection parameter without executing any reconnect logic.
Set the reconnect instance on the connection.
Get the database connection name.
Get the database connection full name.
Get an option from the configuration options.
Get the PDO driver name.
Get the query grammar used by the connection.
Set the query grammar used by the connection.
Get the schema grammar used by the connection.
Set the schema grammar used by the connection.
Get the query post processor used by the connection.
Set the query post processor used by the connection.
Get the event dispatcher used by the connection.
Set the event dispatcher instance on the connection.
Unset the event dispatcher for this connection.
Set the transaction manager instance on the connection.
Unset the transaction manager for this connection.
Determine if the connection is in a "dry run".
Get the connection query log.
Get the connection query log with embedded bindings.
Clear the query log.
Enable the query log on the connection.
Disable the query log on the connection.
Determine whether we're logging queries.
Get the name of the connected database.
Set the name of the connected database.
Set the read / write type of the connection.
Get the table prefix for the connection.
Set the table prefix in use by the connection.
Get the server version for the connection.
Register a connection resolver.
Get the connection resolver for the given driver.
Get the schema state for the connection.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Database/PostgresConnection.html