public static
flDb
|
#
connect( string $master, string $slave = null )
Create an instance of the appropriate database driver object and connect
to the database.
Create an instance of the appropriate database driver object and connect
to the database.
The database names are given in DSN format, driver://username:password@host:port/database
Where: port is optional driver is one of mysql, mysqli, sqlite, sqlite3
Parameters
- $master
- The DSN for the master database.
- $slave
The DSN for the slave database if any or null, if the
driver doesn't support master/slave then this parameter is ignored. The driver is ignored
as it is assumed to be the same as the master.
Returns
flDb The instance of the database driver object.
Throws
|
public
integer
|
#
getQueryCount( )
Get the number of queries.
Get the number of queries.
Returns
integer The number of queries.
|
public
mixed
|
#
escape( mixed $value )
Escape a value.
Parameters
- $value
- The value to escape.
Returns
mixed The escaped value.
|
public
flDbResult
|
#
query( string $query, array $params = array() )
Perform a query on the database.
Perform a query on the database.
? in the query string is replaced with the escaped quoted parameter
Parameters
- $query
- The query string.
- $params
- The array of parameters to use or 1st argument
Returns
Throws
|
public
array
|
#
fetchAll( string $query, array $params = array() )
Fetch an array of all rows.
Fetch an array of all rows.
Parameters
- $query
- The query string.
- $params
- The array of parameters to use or 1st argument
Returns
array Array of rows of false on error.
|
public
array
|
#
fetchRow( string $query, array $params = array() )
Perform a query and return the 1st row.
Perform a query and return the 1st row.
? in the query string is replaced with the escaped quoted parameter
Parameters
- $query
- The query string.
- $params
- The array of parameters to use or 1st argument
Returns
array The row or false.
|
public
mixed
|
#
fetchOne( string $query, array $params = array() )
Perform a query and return the first element of the 1st row.
Perform a query and return the first element of the 1st row.
? in the query string is replaced with the escaped quoted parameter
Parameters
- $query
- The query string.
- $params
- The array of parameters to use or 1st argument
Returns
mixed The item or false.
|
public
array
|
#
maintain( boolean $repair = false )
Optimize or repair tables within the database.
Optimize or repair tables within the database.
Parameters
- $repair
- true to perform a repair or false to optimize.
Returns
array Results for each table.
|
public
boolean
|
#
insert( string $table, array $values )
Insert the given value pairs of key values into the table.
Insert the given value pairs of key values into the table.
Parameters
- $table
- The table to insert the values into.
- $values
- The array of key value pairs of data to insert.
Returns
boolean true if worked; else false.
|
public
boolean
|
#
replace( string $table, array $values )
Replace or insert the given key value pairs in the table.
Replace or insert the given key value pairs in the table.
Parameters
- $table
- The table to replace/insert the values into.
- $values
- The array of key value pairs of data to insert.
Returns
boolean true if worked; else false.
|
public
boolean
|
#
update( string $table, array $values, string $where, array $params )
Update a row in the table.
Update a row in the table.
Parameters
- $table
- The table to update.
- $values
- The array of key/value pairs of data to update.
- $where
- The WHERE clause for selecting the row.
- $params
- The array of parameters to use or 1st argument for use in the WHERE clause.
Returns
boolean true if worked; else false.
|
public
boolean
|
#
delete( string $table, string $where, array $params )
Delete a table from the database.
Delete a table from the database.
Parameters
- $table
- The table to delete.
- $where
- The where clause.
- $params
- Array of parameters to use in the where clause or 1st argument.
Returns
boolean true if deleted; else false.
|
public
string
|
#
lastQuery( )
Get the last query string.
Get the last query string.
Returns
string The last query string.
|
abstract public
mixed
|
#
_escape( mixed $value )
Escape a value in the driver.
Escape a value in the driver.
Parameters
- $value
- The value to escape.
Returns
mixed The escaped value.
|
abstract public
flDbResult
|
#
_query( string $query )
Perform the SQL query in the driver.
Perform the SQL query in the driver.
Parameters
Returns
|
abstract public
integer
|
#
insertID( )
Return the id generated by the last insert operation.
Return the id generated by the last insert operation.
Returns
integer The id.
|
abstract public
integer
|
#
affectedRows( )
Get the number of rows affected by the previous operation.
Get the number of rows affected by the previous operation.
Returns
integer The number of rows affected.
|
abstract public
array
|
#
fetchTables( )
Get the list of tables in the database.
Get the list of tables in the database.
Returns
array The list of tables in the database.
|
abstract public
array
|
#
fetchFields( string $table )
Get the names of all fields in a table.
Get the names of all fields in a table.
Parameters
- $table
- The table to query.
Returns
array An array holding the names of all fields.
|
abstract public
string
|
#
_maintain( boolean $repair, string $table )
Optimize or repair tables within the database.
Optimize or repair tables within the database.
Parameters
- $repair
- true to perform a repair or false to optimize.
- $table
- The name of the table to operate on.
Returns
string The result.
|
abstract public
string
|
#
errorString( )
The error for the previous operation.
The error for the previous operation.
Returns
string The error string.
|
abstract public
string
|
#
version( )
The database server version.
The database server version.
Returns
string The version string.
|