Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
366 lines (235 sloc) 9.5 KB

Quick Start

Connecting and doing a query:

Note

DALMP is the name of the namespace

Will output something like:

DALMP\Database takes the parameters from a DNS (database source name) so before you can start using it you need to define this values.

DSN format

charset://username:password@host:port/database

When using Unix domain sockets:

charset://username:password@unix_socket=\path\of\the.socket/database
  • Notice that the path of the socket is using backslashes.
\path\of\the.socket

Will be translated to:

/path/of/the.socket

DSN Cache format

charset://username:password@host:port/database?(type:host:port:compression)
type:Memcache, Redis, Disk.
host:The host of the Memcache, Redis server.
port:The port of the Memcache, Redis server.
compression:To use or not compression, only available for memcache.

Common methods

The next table contains, 5 common methods for retrieving data:

Name Normal Prepared Statements Cache Normal Cache Prepared Statements
all GetAll PGetAll CacheGetAll CachePGetAll
assoc GetAssoc PGetAssoc CacheGetAssoc CachePGetAssoc
col GetCol PGetCol CacheGetCol CachePGetCol
one GetOne PGetOne CacheGetOne CachePGetOne
row GetRow PGetRow CacheGetRow CachePGetRow

For Inserting or Updating, you can use the Execure or PExecute methods.

DALMP Classes

For better code maintainability, DALMP is formed by different classes, the main class and the one that does the abstraction layer is DALMP\Database.

mysql DALMP\Database
cache DALMP\Cache
queue DALMP\Queue
sessions DALMP\Sessions
DI DALMP\DI

Examples

DSN values

charset:utf8
user:$user
password:$password
host:127.0.0.1
database:test

If you wan to use the system default charset the DSN would be:

  • notice the mysql:// instead of the utf8://

SSL

If you want to use SSL, an array containing the SSL parameters must be passed as the second argument to the database method example:

The $ssl array argument, must follow this format:

key:The path name to the key file.
cert:The path name to the certificate file.
ca:The path name to the certificate authority file.
capath:The pathname to a directory that contains trusted SSL CA certificates in PEM format.
cipher:A list of allowable ciphers to use for SSL encryption.

Note

When using SSL, PHP OpenSSL support must be enable for this to work.

To check that your connection has SSL you can test with this:

If you have SSL you will get something like:

Otherwise:

Example using a socket

Example using cache (memcache)

Example using DSN cache (redis)