Database connection interface

This defines the public methods for making a connection with a database, executing queries, getting information about the query result and closing the connection.

category Database
package Formaid
author Dieter Adriaenssens
copyright 2006-2013 Dieter Adriaenssens
license GPL
link http://formaid.sourceforge.net/

 Methods

Returns the number of rows that was affected by the last statement.

affectedRows() : int

Returns

intreturns number of affected rows

Closes connection to the database

close() : bool

Returns

boolis true when closing is successful.

Makes a connection with a database.

connect(string $server, string $username, string $password, string $database) : bool

Parameters

$server

string

Hostname or IP address of the database server

$username

string

Username to connect to the database server

$password

string

Password to login to the database server

$database

string

Database

Returns

boolis true when connection was made succesfully

Returns an escaped string.

escapeString(string $string) : string

Parameters

$string

string

string to be escaped

Returns

stringescaped string.

Returns the ID of last executed query.

lastInsertId() : int

Returns

intreturns ID for an AUTO_INCREMENT field of last executed query

Returns the number of rows that was returned by the last statement, or the result provided by a parameter.

numRows(mixed $result) : int

Parameters

$result

mixed

result of a SQL query

Returns

intnumber of rows

Executes an SQL query

query(string $query) : \result

Parameters

$query

string

SQL query

Returns

\resultresult of query

Selects a database

selectDb(string $database) : bool

Parameters

$database

string

Database name

Returns

boolis true when switching the database was succesful