PostgresqlEngine
extends DataBaseEngine
in package
Class to connect with PostgreSQL.
Tags
Table of Contents
- $i18n : Translator
- Contains the translator.
- $lastErrorMsg : string
- Last error message.
- $utilsSQL : DataBaseQueries
- Link to the SQL statements for the connected database
- __construct() : mixed
- Postgresql constructor and initialization.
- beginTransaction() : bool
- Starts a SQL transaction
- castInteger() : mixed
- Cast the column to a number
- close() : bool
- Disconnect from the database
- columnFromData() : array<string|int, mixed>
- Converts the sqlColumns return data to a working structure
- commit() : bool
- Commits changes in a SQL transaction
- compareDataTypes() : bool
- Compares the data types from a numeric column. Returns true if they are equal
- connect() : bool|null
- Connects to the database
- dateStyle() : string
- Returns the date format from the database engine
- errorMessage() : string
- Returns the last run statement error
- escapeColumn() : string
- Escapes the column name.
- escapeString() : string
- Escapes quotes from a text string
- exec() : bool
- Runs SQL statement in the database (inserts, updates or deletes)
- getOperator() : string
- Indicates the operator for the database engine
- getSQL() : DataBaseQueries
- Returns the link to the SQL class from the engine
- inTransaction() : bool
- Indicates if the connection has an active transaction
- listTables() : array<string|int, mixed>
- Returns an array with the database table names
- rollback() : bool
- Rolls back a transaction
- select() : array<string|int, mixed>
- Runs a SELECT SQL statement
- updateSequence() : mixed
- version() : string
- Return the used engine and the version.
- runSql() : array<string|int, mixed>|bool
- Runs a SELECT SQL statement, and returns an array with the results when $selectRows= true, or an empty array if it fails.
Properties
$i18n
Contains the translator.
protected
Translator
$i18n
$lastErrorMsg
Last error message.
protected
string
$lastErrorMsg
= ''
$utilsSQL
Link to the SQL statements for the connected database
private
DataBaseQueries
$utilsSQL
Methods
__construct()
Postgresql constructor and initialization.
public
__construct() : mixed
Return values
mixed —beginTransaction()
Starts a SQL transaction
public
beginTransaction(resource $link) : bool
Parameters
- $link : resource
Return values
bool —castInteger()
Cast the column to a number
public
castInteger(mixed $link, mixed $column) : mixed
Parameters
- $link : mixed
- $column : mixed
Return values
mixed —close()
Disconnect from the database
public
close(resource $link) : bool
Parameters
- $link : resource
Return values
bool —columnFromData()
Converts the sqlColumns return data to a working structure
public
columnFromData(array<string|int, mixed> $colData) : array<string|int, mixed>
Parameters
- $colData : array<string|int, mixed>
Return values
array<string|int, mixed> —commit()
Commits changes in a SQL transaction
public
commit(resource $link) : bool
Parameters
- $link : resource
Return values
bool —compareDataTypes()
Compares the data types from a numeric column. Returns true if they are equal
public
compareDataTypes(string $dbType, string $xmlType) : bool
Parameters
- $dbType : string
- $xmlType : string
Return values
bool —connect()
Connects to the database
public
connect(string &$error) : bool|null
Parameters
- $error : string
Return values
bool|null —dateStyle()
Returns the date format from the database engine
public
dateStyle() : string
Return values
string —errorMessage()
Returns the last run statement error
public
errorMessage(resource $link) : string
Parameters
- $link : resource
Return values
string —escapeColumn()
Escapes the column name.
public
escapeColumn(resource $link, string $name) : string
Parameters
- $link : resource
- $name : string
Return values
string —escapeString()
Escapes quotes from a text string
public
escapeString(resource $link, string $str) : string
Parameters
- $link : resource
- $str : string
Return values
string —exec()
Runs SQL statement in the database (inserts, updates or deletes)
public
exec(resource $link, string $sql) : bool
Parameters
- $link : resource
- $sql : string
Return values
bool —getOperator()
Indicates the operator for the database engine
public
getOperator(string $operator) : string
Parameters
- $operator : string
Return values
string —getSQL()
Returns the link to the SQL class from the engine
public
getSQL() : DataBaseQueries
Return values
DataBaseQueries —inTransaction()
Indicates if the connection has an active transaction
public
inTransaction(resource $link) : bool
Parameters
- $link : resource
Return values
bool —listTables()
Returns an array with the database table names
public
listTables(resource $link) : array<string|int, mixed>
Parameters
- $link : resource
Return values
array<string|int, mixed> —rollback()
Rolls back a transaction
public
rollback(resource $link) : bool
Parameters
- $link : resource
Return values
bool —select()
Runs a SELECT SQL statement
public
select(resource $link, string $sql) : array<string|int, mixed>
Parameters
- $link : resource
- $sql : string
Return values
array<string|int, mixed> —updateSequence()
public
updateSequence(resource $link, string $tableName, array<string|int, mixed> $fields) : mixed
Parameters
- $link : resource
- $tableName : string
- $fields : array<string|int, mixed>
Return values
mixed —version()
Return the used engine and the version.
public
version(resource $link) : string
Parameters
- $link : resource
Return values
string —runSql()
Runs a SELECT SQL statement, and returns an array with the results when $selectRows= true, or an empty array if it fails.
private
runSql(resource $link, string $sql[, bool $selectRows = true ]) : array<string|int, mixed>|bool
Parameters
- $link : resource
- $sql : string
- $selectRows : bool = true