MySQL database class
This class provides specific functionality to connect to a MySQL database : - connecting to a database server - selecting a database - performing a query - handle returned data - get info about the query - get info about the database server - close connection to the database - error handling
category | Database |
---|---|
package | Formaid |
author | Dieter Adriaenssens |
copyright | 2006-2013 Dieter Adriaenssens |
license | GPL |
link | http://formaid.sourceforge.net/ |
__construct(string $server, string $username, string $password, string $database) : void
Settings with parameters.
string
Hostname or IP address of the database server
string
Username to connect to the database server
string
Password to login to the database server
string
Database
affectedRows() : int
This gives a result only with INSERT, UPDATE, REPLACE and DELETE statements.
int
returns number of affected rowsclose() : bool
bool
is true when closing is successful.connect(string $server, string $username, string $password, string $database) : bool
Uses servername, username, password and database from the configfile, unless they are provided as parameters. The provided parameters are not stored and override the values in the configfile. When a database parameter is provided, a database is selected after successfully connecting to the database server.
string
Hostname or IP address of the database server
string
Username to connect to the database server
string
Password to login to the database server
string
Database
bool
is true when connection was made succesfullyescapeString(string $string) : string
Special characters in given string are escaped.
string
string to be escaped
string
returns escaped string.getInstance() : object
access | public |
---|---|
inherited_from | \Formaid_DbAbstract::getInstance() |
object
lastInsertId() : int
This gives a result only when a field was updated with AUTO_INCREMENT, usually when executing a INSERT query.
int
returns ID for an AUTO_INCREMENT field of last executed query.numRows(mixed $result) : int
This gives a result only with SELECT and SHOW statements.
mixed
result of a db query
int
number of rowsprepareSqlField(string $field) : string
name of database or table), for use in an SQL query.
inherited_from | \PrepareQueryInterface::prepareSqlField() |
---|
string
database or table name
string
formatted field nameprepareSqlValue(string $value) : string
Quotes are added and the submitted value is properly escaped.
inherited_from | \PrepareQueryInterface::prepareSqlValue() |
---|
string
value of a variable to be used in an SQL string
string
escaped stringquery(string $query) : \result
If a connection with a database was made, the SQL query is executed. If not, a connection is first made.
string
SQL query
\result
result of queryselectDb(string $database) : bool
Uses a database name from the configfile, unless it is provided as a parameter. The provided parameter is not stored and overrides the value in the configfile.
string
Database name
bool
is true when switching the database was succesfulconnectToServer(string $server, string $username, string $password) : bool
This method makes the actual connection to the MySQL database server.
string
Hostname or IP address of the database server
string
Username to connect to the database server
string
Password to login to the database server
bool
is true when connection was made succesfully_hasConnection() : bool
inherited_from | \Formaid_DbAbstract::_hasConnection() |
---|
bool
is true when a connection was made._hasQuery(mixed $result) : bool
inherited_from | \Formaid_DbAbstract::_hasQuery() |
---|
mixed
result of a SQL query
bool
is true when a query was executed.$connection : resource
access | protected |
---|---|
inherited_from | \Formaid_DbAbstract::$$connection |
$database : string
access | protected |
---|---|
inherited_from | \Formaid_DbAbstract::$$database |
$password : string
access | protected |
---|---|
inherited_from | \Formaid_DbAbstract::$$password |
$result : \result
access | private |
---|---|
inherited_from | \Formaid_DbAbstract::$$result |
$server : string
access | protected |
---|---|
inherited_from | \Formaid_DbAbstract::$$server |
$username : string
access | protected |
---|---|
inherited_from | \Formaid_DbAbstract::$$username |
$_instance
access | private |
---|---|
type | object |
inherited_from | \Formaid_DbAbstract::$$_instance |