Source API for the «Porte» class

Central class to the Porte Library with access to configuration, model definitions as well as connection resource.

The class can be used as a Record factory to create new records and load existing records. Simply call the property or method named as a record type.

The class can also be used as a broker of table objects. Simply call the property or method named as the plural version of a record type.

Exemples:

PHP magic methods

__construct

Constructor may be called as follow:

  • With no parameter:
    Values are obtained from Porte static properties
  • With a config array:
    "host": IP address or host name, default to 127.0.0.1
    "username": Mysql username
    "password": Mysql password
    "port": Mysql connection port, default to 3306 for mysql
    "database": set the default database
    "encoding": set the connection encoding, default to PHP encoding
  • With a PHP connection resource:
    Expect a valid resource

The resource associated to a database connection is lazy loaded. It is not created in the constructor but the first time a resource is requested.

If a default timezone in not registered inside the PHP process, it will be set with the value "UTC". This behavior is required by PHP time functions if strict mode is enabled.

__destruct

This method is not yet documented.

__isset

Overwritte PHP magick method to provide a wrapper around internal properties.

__get

Overwritte PHP magick method. It is used for the following reasons:

  • A shortcut to create new record objects by using the record type as the property name.
  • A shortcut to access table object for a provided record type by using the plural value of a record type as the property name.
  • A mechanism to lazy load the following properties: resource, host, port, username, password, and database.
__call

Overwritte PHP magick method. It is used for the following reasons:

  • A shortcut to create new record objects or load stored records objects by using the record type as the property name.
  • A shortcut to access table object for a provided record type by using the plural value of a record type as the property name.
    Both type of methods may be invoked in a "get" form.

Public methods

destruct

This method is not yet documented.

getConnection

Return the current connection object.

setConnection

Set a new connection.

exec

Wrapper around the "$this->connection->exec" method call.

query

Wrapper around the "$this->connection->query" method call.

prepare

Wrapper around the "$this->connection->prepare" method call.

quote

Wrapper around the "$this->connection->quote" method call.

lastInsertId

Wrapper around the "$this->connection->lastInsertId" method call.