$server
$server :
Base class for a database table's class Every table must have a derived class with the check function Example:
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; } ... }
__construct(string $table, array $fields, array $pk, array $uniques = NULL)
Constructor
string | $table | The table on the database |
array | $fields | Associative array with the fields of the table and their check functions |
array | $pk | Array with the PKs of the table. It can contains the key "autoincrement", if the field is an autoincrement field |
array | $uniques | If not NULL, array of arrays, with the unique keys. Every entry is an array with all field for this unique key |
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
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)
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