Basic database class, from which specific database classes derive.
This class provides an interface and basic functionality : - 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() : bool
This gives a result only with INSERT, UPDATE, REPLACE and DELETE statements.
bool
returns true if connection was made and a query was executed.close() : bool
inherited_from | \DbInterface::close() |
---|
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.
First, a connection is made to the database server. After successfully connecting to the database server, a database is selected.
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) : bool
Special characters in given string are escaped.
string
string to be escaped
bool
true if string is not empty and if connection was madegetInstance() : object
access | public |
---|
object
lastInsertId() : bool
This gives a result only when a field was updated with AUTO_INCREMENT, usually when executing a INSERT query.
bool
true if a connection was madenumRows(mixed $result) : bool
This gives a result only with SELECT and SHOW statements.
mixed
result of a SQL query
bool
returns true if connection was made and a query was executed.prepareSqlField(string $field) : string
name of database or table), for use in an SQL query.
Quotes are added to the database or table name.
string
database or table name
string
formatted field nameprepareSqlValue(string $value) : string
Quotes are added and the submitted value is properly escaped.
string
value of a variable to be used in an SQL string
string
escaped stringquery(string $query) : bool
If a connection with a database was made, the SQL query is executed. If not, an error is thrown.
string
SQL query
bool
returns true if the query is not empty and a connection was madeselectDb(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 database server. This method is overridden by child classes for a specific database type.
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
bool
is true when a connection was made._hasQuery(mixed $result) : bool
mixed
result of a SQL query
bool
is true when a query was executed.$connection : resource
access | protected |
---|
$database : string
access | protected |
---|
$password : string
access | protected |
---|
$result : \result
access | private |
---|
$server : string
access | protected |
---|
$username : string
access | protected |
---|
$_instance
access | private |
---|---|
type | object |