\Database

Database connection class. This class is used for instantiate a singleton object for database connection.

Summary

Methods
Properties
Constants
singleton()
__call()
isConnected()
__get()
__set()
getSchema()
getName()
getDbms()
getHost()
getPort()
getUser()
lastId()
nextId()
tableExists()
getPrimaryColumn()
isUnique()
columnExists()
getMandatoryColumns()
toValue()
toBind()
fromDb()
toSql()
toOrder()
size()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
__construct()
$database
$connection
$array
N/A

Properties

$database

$database : \Database

This variable assure the existance of a unique Database object instance.

Type

\Database

$connection

$connection : \PDO

For PDO connection record.

Type

\PDO

$array

$array : string

Schema of database.

Type

string

Methods

singleton()

singleton() : \Database

Singleton function.

Returns

\Database

__call()

__call(string  $function, array  $args) : mixed

Magic method for call PDO methods by Database object.

Parameters

string $function
array $args

Returns

mixed

isConnected()

isConnected() : boolean

Verify connection.

Returns

boolean

__get()

__get(  $key) 

Parameters

$key

__set()

__set(  $key,   $value) 

Parameters

$key
$value

getSchema()

getSchema() : string

Get default schema.

Returns

string

getName()

getName() 

getDbms()

getDbms() 

getHost()

getHost() 

getPort()

getPort() 

getUser()

getUser() 

lastId()

lastId(string  $table, string  $primary = NULL) : integer

Get the last serial inserted value in table.

Parameters

string $table
string $primary

Returns

integer

nextId()

nextId(string  $table, string  $primary = NULL) : integer

Reserve and return de next serial value for table.

Parameters

string $table
string $primary

Returns

integer

tableExists()

tableExists(  $name) 

Parameters

$name

getPrimaryColumn()

getPrimaryColumn(  $table) 

Parameters

$table

isUnique()

isUnique(  $table,   $column) 

Parameters

$table
$column

columnExists()

columnExists(  $table,   $column) 

Parameters

$table
$column

getMandatoryColumns()

getMandatoryColumns(  $table) 

Parameters

$table

toValue()

toValue(\Type  $field) : string

Returns formatted values for build SQL string.

Parameters

\Type $field

Returns

string

toBind()

toBind(\Type  $field) : string

Returns formatted values for build PDO bind SQL string.

Parameters

\Type $field

Returns

string

fromDb()

fromDb(\Type  $field,   $obj) : \Type

Format DB value for load in class.

Parameters

\Type $field
$obj

Returns

\Type

toSql()

toSql(\Type  $field) : string

Get DB column name from field.

Parameters

\Type $field

Returns

string

toOrder()

toOrder(\Type  $field) : string

Get DB column name from field for statement order use.

Parameters

\Type $field

Returns

string

size()

size() 

__construct()

__construct() 

Class constructor.

Designed for singleton.