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.
stringHostname or IP address of the database server
stringUsername to connect to the database server
stringPassword to login to the database server
stringDatabase
affectedRows() : bool
This gives a result only with INSERT, UPDATE, REPLACE and DELETE statements.
boolreturns true if connection was made and a query was executed.close() : bool
| inherited_from | \DbInterface::close() |
|---|
boolis 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.
stringHostname or IP address of the database server
stringUsername to connect to the database server
stringPassword to login to the database server
stringDatabase
boolis true when connection was made succesfullyescapeString(string $string) : bool
Special characters in given string are escaped.
stringstring to be escaped
booltrue if string is not empty and if connection was madegetInstance() : object
| access | public |
|---|
objectlastInsertId() : bool
This gives a result only when a field was updated with AUTO_INCREMENT, usually when executing a INSERT query.
booltrue if a connection was madenumRows(mixed $result) : bool
This gives a result only with SELECT and SHOW statements.
mixedresult of a SQL query
boolreturns 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.
stringdatabase or table name
stringformatted field nameprepareSqlValue(string $value) : string
Quotes are added and the submitted value is properly escaped.
stringvalue of a variable to be used in an SQL string
stringescaped stringquery(string $query) : bool
If a connection with a database was made, the SQL query is executed. If not, an error is thrown.
stringSQL query
boolreturns 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.
stringDatabase name
boolis 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.
stringHostname or IP address of the database server
stringUsername to connect to the database server
stringPassword to login to the database server
boolis true when connection was made succesfully_hasConnection() : bool
boolis true when a connection was made._hasQuery(mixed $result) : bool
mixedresult of a SQL query
boolis 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 |