Jelix 1.6.40

jDbPDOConnection extends PDO
in package

A connection object based on PDO

Tags
subpackage

db

Table of Contents

$dbms  : string
The database type name (mysql, pgsql ...) It is not the driver name. Several drivers could connect to the same database type. This type name is often used to know whish SQL language we should use.
$driverName  : string
driver name
$profile  : array<string|int, mixed>
the profile the connection is using
$_tools  : jDbTools
$_mysqlCharsets  : mixed
$_pgsqlCharsets  : mixed
__construct()  : mixed
Use a profile to do the connection
encloseName()  : string
enclose the field name
getProfileName()  : mixed
hasTablePrefix()  : bool
Check if the current connection has a table prefix set
lastIdInTable()  : int
return the maximum value of the given primary key in a table
lastInsertId()  : string
Get the ID of the last inserted row Mssql pdo driver does not support this feature.
limitQuery()  : jDbPDOResultSet|bool
Launch a SQL Query with limit parameter (so only a subset of a result)
prefixTable()  : string
Prefix the given table with the prefix specified in the connection's profile If there's no prefix for the connection's profile, return the table's name unchanged.
quote2()  : string
Escape and quotes strings. if null, will only return the text "NULL"
setAutoCommit()  : mixed
sets the autocommit state
tools()  : jDbTools
_parseSqlitePath()  : mixed
limitQuerySqlsrv()  : string
Create a limitQuery for the SQL server dbms

Properties

$dbms

The database type name (mysql, pgsql ...) It is not the driver name. Several drivers could connect to the same database type. This type name is often used to know whish SQL language we should use.

public string $dbms

$_mysqlCharsets

private mixed $_mysqlCharsets = array('UTF-8' => 'utf8', 'ISO-8859-1' => 'latin1')

$_pgsqlCharsets

private mixed $_pgsqlCharsets = array('UTF-8' => 'UNICODE', 'ISO-8859-1' => 'LATIN1')

Methods

__construct()

Use a profile to do the connection

public __construct(array<string|int, mixed> $profile) : mixed
Parameters
$profile : array<string|int, mixed>

the profile data readed from the ini file

Return values
mixed

encloseName()

enclose the field name

public encloseName(string $fieldName) : string
Parameters
$fieldName : string

the field name

Tags
since
1.1.2
Return values
string

the enclosed field name

hasTablePrefix()

Check if the current connection has a table prefix set

public hasTablePrefix() : bool
Tags
author

Julien Issler

since
1.0
Return values
bool

lastIdInTable()

return the maximum value of the given primary key in a table

public lastIdInTable(string $fieldName, string $tableName) : int
Parameters
$fieldName : string

the name of the primary key

$tableName : string

the name of the table

Return values
int

the maximum value

lastInsertId()

Get the ID of the last inserted row Mssql pdo driver does not support this feature.

public lastInsertId([string $fromSequence = null ]) : string

so, we use a custom query

Parameters
$fromSequence : string = null

the sequence name, if needed

Return values
string

limitQuery()

Launch a SQL Query with limit parameter (so only a subset of a result)

public limitQuery(string $queryString[, int $limitOffset = null ][, int $limitCount = null ]) : jDbPDOResultSet|bool
Parameters
$queryString : string

the SQL query

$limitOffset : int = null

the offset of the first row to return

$limitCount : int = null

the maximum of number of rows to return

Return values
jDbPDOResultSet|bool

SQL Select. False if the query has failed.

prefixTable()

Prefix the given table with the prefix specified in the connection's profile If there's no prefix for the connection's profile, return the table's name unchanged.

public prefixTable(mixed $table_name) : string
Parameters
$table_name : mixed
Tags
author

Julien Issler

since
1.0
Return values
string

the prefixed table's name

quote2()

Escape and quotes strings. if null, will only return the text "NULL"

public quote2(string $text[, bool $checknull = true ][, bool $binary = false ]) : string
Parameters
$text : string

string to quote

$checknull : bool = true

if true, check if $text is a null value, and then return NULL

$binary : bool = false

set to true if $text contains a binary string

Tags
since
1.2
todo

$binary parameter is not really supported, check if PDOConnection::quote supports binary strings

Return values
string

escaped string

setAutoCommit()

sets the autocommit state

public setAutoCommit([bool $state = true ]) : mixed
Parameters
$state : bool = true

the status of autocommit

Return values
mixed

_parseSqlitePath()

protected _parseSqlitePath(mixed $path) : mixed
Parameters
$path : mixed
Return values
mixed

limitQuerySqlsrv()

Create a limitQuery for the SQL server dbms

protected limitQuerySqlsrv(string $queryString[, int $limitOffset = null ][, int $limitCount = null ]) : string
Parameters
$queryString : string

the SQL query

$limitOffset : int = null

the offset of the first row to return

$limitCount : int = null

the maximum of number of rows to return

Return values
string

SQL Select.

Search results