$table
$table :
Generic class to query the database
class testDB extends myMVC_BaseDB
{
public function construct()
{
parent::construct('test',
array('id' => 'testDB::checkId',
'firstname' => 'testDB::checkName',
'lastname' => 'testDB::checkName',
),
array('id' => 'autoincrement'),
// Unique Key: firstname+lastname
array(array('firstname', 'lastname')));
}
public static checkId($type, $value) { return true; } ... }
callFinder(string $name, array $fields, string $order = NULL, integer $limit = NULL, integer $offset = NULL) : array
Calls a defined finder (see registerFinder)
string | $name | The name of the finder |
array | $fields | An associative array with the fields to use for the search (field => value) |
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
On invalid field
On Problems
The result as array of database class or NULL if no record was found
callIterator(string $name, array $fields, string $order = NULL, integer $limit = NULL, integer $offset = NULL) : resource
Iterate throws a defined finder (see registerFinder)
string | $name | The name of the finder |
array | $fields | An associative array with the fields to use for the search (field => value) |
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
On invalid field
On Problems
The result as database resource or NULL if no record was found
callCounter(string $name, array $fields) : integer
Calls a defined counter (see registerCounter)
string | $name | The name of the counter |
array | $fields | An associative array with the fields to use for the search (field => value) |
On invalid field
On Problems
The count of the searched records
findAll(string $order = NULL, integer $limit = NULL, integer $offset = NULL) : array
Returns all records
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
On invalid field
On Problems
The result as array of database class or NULL if no record was found
iterateAll(string $order = NULL, integer $limit = NULL, integer $offset = NULL) : resource
Iterate all records
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
On invalid field
On Problems
The result as database resource or NULL if no record was found
sqlExportByParameter(array $param, array $useLike = array(), string $order = NULL, integer $limit = NULL, integer $offset = NULL, boolean $exportToBrowser = true, integer $separateAfter = 50) : string
Export data as SQL queries, using parameters Exportiert Datensätze als SQL anhand der eingegebenen Parametern
array | $param | The parameters, as associative array field => value |
array | $useLike | Associative array with the fields that should be search with a LIKE (default: empty) |
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
boolean | $exportToBrowser | If true (default) data will be exported to the browser If false, data will be exported in the return string |
integer | $separateAfter | After $separateAfter lines (default 50) a new SQL header (INSERT INTO...) will be added |
On invalid field
On generic problem
The export as SQL queries or NULL if no data is available
executeQuery(string $sql, boolean $linear = false, $assoc = false) : array
Sends the given query to the engine an returns the result as array
string | $sql | The SQL query |
boolean | $linear | If true, all data will returned as one numeric array, otherwise (default) they will returned as array of arrays |
$assoc | If true data will be returned as associative array. Default: false |
On generic problem
The result as array of arrays or NULL if no data was found
quoteSqlForLike(string $value, string $prefix = '%', string $suffix = '%') : string
Quotes a string to use in a SQL-Query (with LIKE)
string | $value | The string with the Query |
string | $prefix | (normally %) added BEFORE the string |
string | $suffix | (normally %) added AFTER the string |
A secure SQL-String (quoted)
registerFinder(string $name, array $fieldsToSearch, array $fixedFields = array())
Register a new finder method.
This can be called with the method callFinder or iterateFinder.
string | $name | The name of the finder |
array | $fieldsToSearch | An associative array with the fields to use for the search Format of the array: field => "LIKE" or field => "EQUAL" |
array | $fixedFields | An associative array with the "fixed" fields for the search (default: empty) Format of the array: field => value |
On Problems
registerCounter(string $name, array $fieldsToSearch, array $fixedFields = array())
Register a new counter method.
This can be called with the method callCounter.
string | $name | The name of the counter |
array | $fieldsToSearch | An associative array with the fields to use for the search Format of the array: field => "LIKE" or field => "EQUAL" |
array | $fixedFields | An associative array with the "fixed" fields for the search (default: empty) Format of the array: field => value |
On Problems
createWhere(array $param, array $useLike = array())
Creates the WHERE-statement for the SQL query, using parameters
array | $param | The parameters, as associative array field => value |
array | $useLike | Associative array with the fields that should be search with a LIKE (default: empty) |
findByParameter(array $param, array $useLike = array(), string $order = NULL, integer $limit = NULL, integer $offset = NULL) : resource
Get a record from the database, using parameters
array | $param | The parameters, as associative array field => value |
array | $useLike | Associative array with the fields that should be search with a LIKE (default: empty) |
string | $order | If not NULL, field(s) to sort data |
integer | $limit | If not NULL, maximum of the searched data (useful for paging) |
integer | $offset | If not NULL, offset of the searched data (useful for paging) |
On invalid field
On generic problem
The result as database resource or NULL if no data was found
getCountByParameter(array $param, array $useLike = array()) : integer
Get the count of the records, using parameters
array | $param | The parameters, as associative array field => value |
array | $useLike | Associative array with the fields that should be search with a LIKE (default: empty) |
On invalid field
On generic problem
The count of the record
quoteSqlStringForLike(string $value, string $prefix = '%', string $suffix = '%') : string
Quotes a string to use in a SQL-Query (with LIKE)
string | $value | The string with the Query |
string | $prefix | (normally %) added BEFORE the string |
string | $suffix | (normally %) added AFTER the string |
A secure SQL-String (quoted)