Calls a defined counter (see registerCounter)
int
callCounter
(string $name, array $fields)
-
string
$name: The name of the counter
-
array
$fields: An associative array with the fields to use for the search (field => value)
Calls a defined finder (see registerFinder)
array
callFinder
(string $name, array $fields, [string $order = NULL], [int $limit = NULL], [int $offset = NULL])
-
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
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$offset: If not NULL, offset of the searched data (useful for paging)
Iterate throws a defined finder (see registerFinder)
resource
callIterator
(string $name, array $fields, [string $order = NULL], [int $limit = NULL], [int $offset = NULL])
-
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
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$offset: If not NULL, offset of the searched data (useful for paging)
Deletes all records that match the given parameters
void
deleteAll
(array $param)
-
array
$param: The parameters, as associative array field => value
Returns all records
array
findAll
([string $order = NULL], [int $limit = NULL], [int $offset = NULL])
-
string
$order: If not NULL, field(s) to sort data
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$offset: If not NULL, offset of the searched data (useful for paging)
Get a record using the primary key of the table
DB-Class
findByPK
(array $pk)
-
array
$pk: The primary key as associative array (field => value)
Returns the count of all records
int
getCountAll
()
Iterate all records
resource
iterateAll
([string $order = NULL], [int $limit = NULL], [int $offset = NULL])
-
string
$order: If not NULL, field(s) to sort data
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$offset: If not NULL, offset of the searched data (useful for paging)
Constructor
myMVC_BaseDB
__construct
(string $table, array $fields, array $pk, [array $uniques = NULL])
-
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
Redefinition of:
- myMVC_DatabaseConnector::__construct()
- Constructor. Initializes the database connection
Redefined in descendants as:
Checks if all the given data are valid
void
checkFields
(array $param, string $type)
-
array
$param: The data to check
-
string
$type: Check type (save/search)
Checks if the unique keys are satisfied
void
checkUniques
()
Creates the WHERE-statement for the SQL query, using parameters
string
createWhere
(array $param, [array $useLike = array()])
-
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)
Deletes the record, using the primary key
void
delete
()
Get a record from the database, using parameters
resource
findByParameter
(array $param, [array $useLike = array()], [string $order = NULL], [int $limit = NULL], [int $offset = NULL])
-
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
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$offset: If not NULL, offset of the searched data (useful for paging)
Sends to the database engine an SQL query and get the result
resource
findBySQLQuery
(string $sql)
-
string
$sql: The SQL query
Get the count of the records, using parameters
int
getCountByParameter
(array $param, [array $useLike = array()])
-
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)
Check whether the current record satisfies all unique keys
bool
isRecordUnique
()
Returns the current date and time, formatted as for insert in the database
string
now
()
Returns the current date and time, formatted as in the current locale
string
nowFormatted
()
Register a new counter method.
This can be called with the method callCounter.
void
registerCounter
(string $name, array $fieldsToSearch, [array $fixedFields = array()])
-
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
Register a new finder method.
This can be called with the method callFinder or iterateFinder.
void
registerFinder
(string $name, array $fieldsToSearch, [array $fixedFields = array()])
-
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
Save the data. It checks the PK: if the record does not exists, create a new record.
Otherwise it updates it.
void
save
()
Saves the values of the record
void
saveValues
(array $values)
-
array
$values: Associative array with the values from the database
Export data as SQL queries, using parameters Exportiert Datensätze als SQL anhand der eingegebenen Parametern
string
sqlExportByParameter
(array $param, [array $useLike = array()], [string $order = NULL], [int $limit = NULL], [int $offset = NULL], [boolean $exportToBrowser = true], [int $separateAfter = 50])
-
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
-
int
$limit: If not NULL, maximum of the searched data (useful for paging)
-
int
$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
-
int
$separateAfter: After $separateAfter lines (default 50) a new SQL header (INSERT INTO...) will be added
Dynamic get|set method If the function does not exists (unknown get|set Key), an error will be displayed
void
__call
($name $name, $args $args)
-
$name
$name: The name of the unknown called function
-
$args
$args: The arguments
Inherited Methods
Inherited From myMVC_DatabaseConnector
myMVC_DatabaseConnector::__construct()
myMVC_DatabaseConnector::errno()
myMVC_DatabaseConnector::error()
myMVC_DatabaseConnector::execute()
myMVC_DatabaseConnector::executeSelect()
myMVC_DatabaseConnector::freeResult()
myMVC_DatabaseConnector::getDatabaseConnection()
myMVC_DatabaseConnector::getRowsNum()
myMVC_DatabaseConnector::getValueArrayFromResult()
myMVC_DatabaseConnector::getValuesFromResult()
myMVC_DatabaseConnector::quoteSqlString()
myMVC_DatabaseConnector::quoteSqlStringForLike()
Inherited From myMVC_TypeCheck
myMVC_TypeCheck::checkAutoIncrementalId()
myMVC_TypeCheck::checkBoolNotNull()
myMVC_TypeCheck::checkBoolNull()
myMVC_TypeCheck::checkDateNotNull()
myMVC_TypeCheck::checkDateNull()
myMVC_TypeCheck::checkDateTimeNotNull()
myMVC_TypeCheck::checkDateTimeNull()
myMVC_TypeCheck::checkDomainnameNotNull()
myMVC_TypeCheck::checkDomainnameNull()
myMVC_TypeCheck::checkEMailNotNull()
myMVC_TypeCheck::checkEMailNull()
myMVC_TypeCheck::checkIPNotNull()
myMVC_TypeCheck::checkIPNull()
myMVC_TypeCheck::checkMacNotNull()
myMVC_TypeCheck::checkMacNull()
myMVC_TypeCheck::checkMaskNotNull()
myMVC_TypeCheck::checkMaskNull()
myMVC_TypeCheck::checkNetworkNotNull()
myMVC_TypeCheck::checkNetworkNull()
myMVC_TypeCheck::checkSignedIntNotNull()
myMVC_TypeCheck::checkSignedIntNull()
myMVC_TypeCheck::checkSignedMediumIntNotNull()
myMVC_TypeCheck::checkSignedMediumIntNull()
myMVC_TypeCheck::checkSignedSmallIntNotNull()
myMVC_TypeCheck::checkSignedSmallIntNull()
myMVC_TypeCheck::checkSignedTinyIntNotNull()
myMVC_TypeCheck::checkSignedTinyIntNull()
myMVC_TypeCheck::checkString255NotNull()
myMVC_TypeCheck::checkString255Null()
myMVC_TypeCheck::checkTextNotNull()
myMVC_TypeCheck::checkTextNull()
myMVC_TypeCheck::checkTimeNotNull()
myMVC_TypeCheck::checkTimeNull()
myMVC_TypeCheck::checkUnsignedIntNotNull()
myMVC_TypeCheck::checkUnsignedIntNull()
myMVC_TypeCheck::checkUnsignedMediumIntNotNull()
myMVC_TypeCheck::checkUnsignedMediumIntNull()
myMVC_TypeCheck::checkUnsignedSmallIntNotNull()
myMVC_TypeCheck::checkUnsignedSmallIntNull()
myMVC_TypeCheck::checkUnsignedTinyIntNotNull()
myMVC_TypeCheck::checkUnsignedTinyIntNull()
myMVC_TypeCheck::checkURLNotNull()
myMVC_TypeCheck::checkURLNull()