Pgsql
extends AbstractAdapter
in package
PostgreSQL database adapter class
Tags
Table of Contents
Properties
- $connection : mixed
- Database connection object/resource
- $connectionString : string|null
- Connection string
- $error : mixed
- Error string/object/resource
- $listener : mixed
- Query listener object/resource
- $options : array<string|int, mixed>
- Database connection options
- $parameters : array<string|int, mixed>
- Prepared statement parameters
- $profiler : Profiler|null
- Query profiler
- $result : mixed
- Result object/resource
- $statement : mixed
- Statement object/resource
- $statementIndex : int
- Statement index
- $statementName : string|null
- Prepared statement name
- $statementString : string
- Prepared statement string
- $transactionManager : Manager|null
- Transaction manager
Methods
- __construct() : mixed
- Constructor
- beginTransaction() : Pgsql
- Begin a transaction
- bindParams() : Pgsql
- Bind parameters to a prepared SQL query
- clearError() : AbstractAdapter
- Clear the error
- clearProfiler() : AbstractAdapter
- Clear query profiler
- commit() : Pgsql
- Commit a transaction
- connect() : Pgsql
- Connect to the database
- createSchema() : Schema
- Create Schema builder
- createSql() : Sql
- Create SQL builder
- delete() : int
- Directly execute a DELETE SQL query or prepared statement and return the results
- disconnect() : void
- Disconnect from the database
- escape() : string
- Escape the value
- execute() : Pgsql
- Execute a prepared SQL query
- executeSql() : AbstractAdapter
- Execute a SQL query or prepared statement with params
- fetch() : mixed
- Fetch and return a row from the result
- fetchAll() : array<string|int, mixed>
- Fetch and return all rows from the result
- getConnection() : mixed
- Get the connection object/resource
- getError() : mixed
- Get the error
- getLastId() : int
- Return the last ID of the last query
- getListener() : mixed
- Get query listener
- getNumberOfAffectedRows() : int
- Return the number of affected rows from the last query
- getNumberOfRows() : int
- Return the number of rows from the last query
- getOptions() : array<string|int, mixed>
- Get database connection options
- getProfiler() : Profiler|null
- Get query profiler
- getResult() : mixed
- Get the result object/resource
- getStatement() : mixed
- Get the statement object/resource
- getTables() : array<string|int, mixed>
- Return the tables in the database
- getTransactionDepth() : int
- Get transaction depth
- getVersion() : string
- Return the database version
- hasError() : bool
- Determine whether or not there is an error
- hasOptions() : bool
- Has database connection options
- hasResult() : bool
- Determine whether or not a result resource exists
- hasStatement() : bool
- Determine whether or not a statement resource exists
- hasTable() : bool
- Return if the database has a table
- insert() : int
- Directly execute an INSERT SQL query or prepared statement and return the results
- isConnected() : bool
- Determine whether or not connected
- isSuccess() : bool
- Check if transaction is success
- isTransaction() : bool
- Check if adapter is in the middle of an open transaction
- listen() : mixed
- Add query listener to the adapter
- prepare() : Pgsql
- Prepare a SQL query
- query() : Pgsql
- Execute a SQL query directly
- rollback() : Pgsql
- Rollback a transaction
- select() : array<string|int, mixed>
- Directly execute a SELECT SQL query or prepared statement and return the results
- setError() : AbstractAdapter
- Set the error
- setOptions() : Pgsql
- Set database connection options
- setProfiler() : AbstractAdapter
- Set query profiler
- throwError() : void
- Throw a database error exception
- transaction() : void
- Execute complete transaction with the DB adapter
- update() : int
- Directly execute an UPDATE SQL query or prepared statement and return the results
- getTransactionManager() : Manager
- Return the transaction manager object, initialize on first use
Properties
$connection
Database connection object/resource
protected
mixed
$connection
= null
$connectionString
Connection string
protected
string|null
$connectionString
= null
$error
Error string/object/resource
protected
mixed
$error
= null
$listener
Query listener object/resource
protected
mixed
$listener
= null
$options
Database connection options
protected
array<string|int, mixed>
$options
= []
$parameters
Prepared statement parameters
protected
array<string|int, mixed>
$parameters
= []
$profiler
Query profiler
protected
Profiler|null
$profiler
= null
$result
Result object/resource
protected
mixed
$result
= null
$statement
Statement object/resource
protected
mixed
$statement
= null
$statementIndex
Statement index
protected
static int
$statementIndex
= 0
$statementName
Prepared statement name
protected
string|null
$statementName
= null
$statementString
Prepared statement string
protected
string
$statementString
= null
$transactionManager
Transaction manager
protected
Manager|null
$transactionManager
= null
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Instantiate the PostgreSQL database connection object
Parameters
- $options : array<string|int, mixed> = []
beginTransaction()
Begin a transaction
public
beginTransaction() : Pgsql
Return values
PgsqlbindParams()
Bind parameters to a prepared SQL query
public
bindParams(array<string|int, mixed> $params) : Pgsql
Parameters
- $params : array<string|int, mixed>
Return values
PgsqlclearError()
Clear the error
public
clearError() : AbstractAdapter
Return values
AbstractAdapterclearProfiler()
Clear query profiler
public
clearProfiler() : AbstractAdapter
Return values
AbstractAdaptercommit()
Commit a transaction
public
commit() : Pgsql
Return values
Pgsqlconnect()
Connect to the database
public
connect([array<string|int, mixed> $options = [] ]) : Pgsql
Parameters
- $options : array<string|int, mixed> = []
Return values
PgsqlcreateSchema()
Create Schema builder
public
createSchema() : Schema
Return values
SchemacreateSql()
Create SQL builder
public
createSql() : Sql
Return values
Sqldelete()
Directly execute a DELETE SQL query or prepared statement and return the results
public
delete(string|Sql $sql[, array<string|int, mixed> $params = [] ]) : int
Parameters
- $sql : string|Sql
- $params : array<string|int, mixed> = []
Tags
Return values
intdisconnect()
Disconnect from the database
public
disconnect() : void
escape()
Escape the value
public
escape([string|null $value = null ]) : string
Parameters
- $value : string|null = null
Return values
stringexecute()
Execute a prepared SQL query
public
execute() : Pgsql
Return values
PgsqlexecuteSql()
Execute a SQL query or prepared statement with params
public
executeSql(string|Sql $sql[, array<string|int, mixed> $params = [] ]) : AbstractAdapter
Parameters
- $sql : string|Sql
- $params : array<string|int, mixed> = []
Return values
AbstractAdapterfetch()
Fetch and return a row from the result
public
fetch() : mixed
fetchAll()
Fetch and return all rows from the result
public
fetchAll() : array<string|int, mixed>
Return values
array<string|int, mixed>getConnection()
Get the connection object/resource
public
getConnection() : mixed
getError()
Get the error
public
getError() : mixed
getLastId()
Return the last ID of the last query
public
getLastId() : int
Return values
intgetListener()
Get query listener
public
getListener() : mixed
getNumberOfAffectedRows()
Return the number of affected rows from the last query
public
getNumberOfAffectedRows() : int
Tags
Return values
intgetNumberOfRows()
Return the number of rows from the last query
public
getNumberOfRows() : int
Tags
Return values
intgetOptions()
Get database connection options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getProfiler()
Get query profiler
public
getProfiler() : Profiler|null
Return values
Profiler|nullgetResult()
Get the result object/resource
public
getResult() : mixed
getStatement()
Get the statement object/resource
public
getStatement() : mixed
getTables()
Return the tables in the database
public
getTables() : array<string|int, mixed>
Return values
array<string|int, mixed>getTransactionDepth()
Get transaction depth
public
getTransactionDepth() : int
Return values
intgetVersion()
Return the database version
public
getVersion() : string
Return values
stringhasError()
Determine whether or not there is an error
public
hasError() : bool
Return values
boolhasOptions()
Has database connection options
public
hasOptions() : bool
Return values
boolhasResult()
Determine whether or not a result resource exists
public
hasResult() : bool
Return values
boolhasStatement()
Determine whether or not a statement resource exists
public
hasStatement() : bool
Return values
boolhasTable()
Return if the database has a table
public
hasTable(string $table) : bool
Parameters
- $table : string
Return values
boolinsert()
Directly execute an INSERT SQL query or prepared statement and return the results
public
insert(string|Sql $sql[, array<string|int, mixed> $params = [] ]) : int
Parameters
- $sql : string|Sql
- $params : array<string|int, mixed> = []
Tags
Return values
intisConnected()
Determine whether or not connected
public
isConnected() : bool
Return values
boolisSuccess()
Check if transaction is success
public
isSuccess() : bool
Return values
boolisTransaction()
Check if adapter is in the middle of an open transaction
public
isTransaction() : bool
Return values
boollisten()
Add query listener to the adapter
public
listen(mixed $listener[, mixed $params = null ][, Profiler $profiler = new ProfilerProfiler() ]) : mixed
Parameters
- $listener : mixed
- $params : mixed = null
- $profiler : Profiler = new ProfilerProfiler()
prepare()
Prepare a SQL query
public
prepare(mixed $sql) : Pgsql
Parameters
- $sql : mixed
Return values
Pgsqlquery()
Execute a SQL query directly
public
query(mixed $sql) : Pgsql
Parameters
- $sql : mixed
Return values
Pgsqlrollback()
Rollback a transaction
public
rollback() : Pgsql
Return values
Pgsqlselect()
Directly execute a SELECT SQL query or prepared statement and return the results
public
select(string|Sql $sql[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $sql : string|Sql
- $params : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>setError()
Set the error
public
setError(string $error) : AbstractAdapter
Parameters
- $error : string
Return values
AbstractAdaptersetOptions()
Set database connection options
public
setOptions(array<string|int, mixed> $options) : Pgsql
Parameters
- $options : array<string|int, mixed>
Return values
PgsqlsetProfiler()
Set query profiler
public
setProfiler(Profiler $profiler) : AbstractAdapter
Parameters
- $profiler : Profiler
Return values
AbstractAdapterthrowError()
Throw a database error exception
public
throwError([string|null $error = null ]) : void
Parameters
- $error : string|null = null
Tags
transaction()
Execute complete transaction with the DB adapter
public
transaction(mixed $callable[, mixed $params = null ]) : void
Parameters
- $callable : mixed
- $params : mixed = null
Tags
update()
Directly execute an UPDATE SQL query or prepared statement and return the results
public
update(string|Sql $sql[, array<string|int, mixed> $params = [] ]) : int
Parameters
- $sql : string|Sql
- $params : array<string|int, mixed> = []
Tags
Return values
intgetTransactionManager()
Return the transaction manager object, initialize on first use
protected
getTransactionManager() : Manager