static void clearMapping(
)
|
|
Clear the current database mapping.
Redefined in descendants as:
static atkDb &getInstance(
[String
$conn = "default"], [Bool
$reset = false], [String
$mode = "rw"]
)
|
|
Get database instance.
This method instantiates and returns the correct (vendor specific) database instance, depending on the configuration.
Parameters:
|
String |
$conn: |
The name of the connection as defined in the config.inc.php file (defaults to 'default') |
|
Bool |
$reset: |
Reset the instance to force the creation of a new instance |
|
String |
$mode: |
The mode to connect with the database |
API Tags:
| Return: | Instance of the database class. |
| Access: | public |
Redefined in descendants as:
static mixed getMapping(
)
|
|
Returns the current database mapping.
NULL if no mapping is active.
API Tags:
| Return: | current database mapping (null if inactive) |
Redefined in descendants as:
static void getTranslatedDatabaseName(
string
$name
)
|
|
Returns the real database name. If a mapping
exists the mapping is used to translate the database name to it's real database name. If the database name is not part of the mapping or no mapping is set the given name will be returned.
Parameters:
|
string |
$name: |
database name |
Redefined in descendants as:
static void useMapping(
array
$mapping
)
|
|
Use the given mapping to translate database requests from one database to another database. This can be used for test purposes.
Parameters:
|
array |
$mapping: |
database mapping |
Redefined in descendants as:
static mixed _getOrUseMapping(
[array
$mapping = "get"]
)
|
|
Get or set the database mapping
Parameters:
|
array |
$mapping: |
database mapping |
API Tags:
| Return: | current database mapping (null if inactive) |
Redefined in descendants as:
Retrieve the number of rows affected by the last query.
After calling query() to perform an update statement, this method will return the number of rows that was updated.
API Tags:
| Return: | The number of affected rows |
| Abstract: | |
Redefined in descendants as:
void cloneAll(
&$otherDb, atkDb
$otherDb
)
|
|
Clones the database structure of the given database to this database. This also means the complete database is emptied beforehand.
Parameters:
|
atkDb |
$otherDb: |
other database instance |
|
|
&$otherDb: |
|
Redefined in descendants as:
Commit the current transaction.
API Tags:
Redefined in descendants as:
int connect(
[String
$mode = "rw"]
)
|
|
Connect to the database.
Parameters:
|
String |
$mode: |
The mode to connect |
API Tags:
| Return: | Connection status |
| Abstract: | |
Redefined in descendants as:
Create an atkDDL object for constructing ddl queries.
API Tags:
Redefined in descendants as:
Create an atkQuery object for constructing queries.
API Tags:
Redefined in descendants as:
Empty all database tables.
Redefined in descendants as:
Disconnect from database
API Tags:
Redefined in descendants as:
void doConnect(
string
$host, string
$user, string
$password, string
$database, int
$port, string
$charset
)
|
|
Connect to the database
Parameters:
|
string |
$host: |
The host to connect to |
|
string |
$user: |
The user to connect with |
|
string |
$password: |
The password to connect with |
|
string |
$database: |
The database to connect to |
|
int |
$port: |
The portnumber to use for connecting |
|
string |
$charset: |
The charset to use |
API Tags:
Redefined in descendants as:
Drop all database tables.
Redefined in descendants as:
string errorLookup(
integer
$errno
)
|
|
Looks up the error
Parameters:
|
integer |
$errno: |
Error number |
API Tags:
| Return: | The translation for the error |
Redefined in descendants as:
String escapeSQL(
String
$string, [Bool
$wildcard = false]
)
|
|
escapes quotes for use in SQL: ' -> '' (and sometimes % -> %%)
Parameters:
|
String |
$string: |
The string to escape |
|
Bool |
$wildcard: |
Use wildcards? |
API Tags:
| Return: | The escaped SQL string |
Redefined in descendants as:
unknown func_concat(
array
$fields
)
|
|
Get CONCAT() equivalent for the current database.
Parameters:
Redefined in descendants as:
string func_concat_ws(
array
$fields, string
$separator, [boolean
$remove_all_spaces = false]
)
|
|
Get CONCAT_WS() equivalent for the current database.
Parameters:
|
array |
$fields: |
|
|
string |
$separator: |
|
|
boolean |
$remove_all_spaces: |
remove all spaces in result (atkAggrecatedColumns searches for string without spaces) |
Redefined in descendants as:
String func_datetimetochar(
String
$fieldname
)
|
|
Get TO_CHAR() equivalent for the current database.
TODO/FIXME: add format parameter. Current format is always yyyy-mm-dd hh:mi.
Parameters:
|
String |
$fieldname: |
The field to generate the to_char for. |
API Tags:
| Return: | Piece of sql query that converts a datetime field to char for the current database |
Redefined in descendants as:
String func_datetochar(
String
$fieldname, [String
$format = ""]
)
|
|
Get TO_CHAR() equivalent for the current database.
Each database driver should override this method to perform vendor specific conversion.
Parameters:
|
String |
$fieldname: |
The field to generate the to_char for. |
|
String |
$format: |
Format specifier. The format is compatible with php's date() function (http://www.php.net/date) The default is what's specified by $config_date_to_char, or "Y-m-d" if not set in the configuration. |
API Tags:
| Return: | Piece of sql query that converts a date field to char for the current database |
Redefined in descendants as:
get NOW() or SYSDATE() equivalent for the current database
Every database has it's own implementation to get the current date
Redefined in descendants as:
void func_substring(
String
$fieldname, [Integer
$startat = 0], [Integer
$length = 0]
)
|
|
get SUBSTRING() equivalent for the current database.
Parameters:
|
String |
$fieldname: |
The database fieldname |
|
Integer |
$startat: |
The position to start from |
|
Integer |
$length: |
The number of characters |
Redefined in descendants as:
Get generic atk errorccode
API Tags:
| Return: | One of the ATK DB_* codes. |
Redefined in descendants as:
Get vendor-dependent database error number.
Applications should not rely on this method, if they want to be database independent.
API Tags:
| Return: | Database dependent error code. |
Redefined in descendants as:
Get vendor-dependent database error message.
Applications should not rely on this method, if they want to be database independent.
API Tags:
| Return: | Database dependent error message. |
Redefined in descendants as:
DB_SUCCESS getDbStatus(
)
|
|
Check if current db is present and acceptable for current user
API Tags:
Redefined in descendants as:
Get localized error message (for display in the application)
API Tags:
Redefined in descendants as:
Determine whether an error that occurred is a recoverable (user) error or a system error.
API Tags:
| Return: | "user" or "system" |
Redefined in descendants as:
string getQueryMode(
string
$query
)
|
|
Returns the query mode
Parameters:
API Tags:
| Return: | Return r or w mode |
Redefined in descendants as:
array getrows(
string
$query, [int
$offset = -1], [int
$limit = -1]
)
|
|
Get all rows that are the result of a certain specified query
Note: This is not an efficient way to retrieve records, as this will load all records into one array into memory. If you retrieve a lot of records, you might hit the memory_limit and your script will die.
Parameters:
|
string |
$query: |
The query |
|
int |
$offset: |
The offset to use |
|
int |
$limit: |
The limit to use |
API Tags:
Redefined in descendants as:
This function indicates what searchmodes the database supports.
API Tags:
| Return: | with search modes |
Redefined in descendants as:
Get the database driver type.
API Tags:
Redefined in descendants as:
mixed getValue(
string
$query, [mixed
$default = null]
)
|
|
Get a single value (first row, first column) from a certain specified query
Parameters:
|
string |
$query: |
The query |
|
mixed |
$default: |
A default value which will be returned if the query doesn't return a result |
API Tags:
| Return: | Either the result of the query or the default value |
Redefined in descendants as:
array getValues(
string
$query, [string
$key = 0], [int
$offset = -1], [int
$limit = -1]
)
|
|
Get an array with all the values in the (first) column.
Note: This is not an efficient way to retrieve records, as this will load all records into one array into memory. If you retrieve a lot of records, you might hit the memory_limit and your script will die.
Parameters:
|
string |
$query: |
The query |
|
string |
$key: |
You can change the returning column using this parameter |
|
int |
$offset: |
The offset to use |
|
int |
$limit: |
The limit to use |
API Tags:
Redefined in descendants as:
void halt(
[String
$message = ""]
)
|
|
If haltonerror is set, this will raise an atkerror. If not, it will place the error in atkdebug and continue.
Parameters:
API Tags:
Redefined in descendants as:
Has error?
Redefined in descendants as:
bool hasMode(
string
$mode
)
|
|
Check if the current instance has the given mode
Parameters:
|
string |
$mode: |
The mode we want to check |
API Tags:
| Return: | True or False |
| Access: | public |
Redefined in descendants as:
atkDb init(
[String
$connectionname = 'default'], [String
$mode = 'r']
)
|
|
(Re)Initialise a database driver with a connection
Parameters:
|
String |
$connectionname: |
The connectionname |
|
String |
$mode: |
The mode to connect with |
API Tags:
Redefined in descendants as:
Get the current connection.
API Tags:
Redefined in descendants as:
boolean lock(
String
$table, [String
$mode = "write"]
)
|
|
Lock a table in the database.
Parameters:
|
String |
$table: |
The name of the table to lock. |
|
String |
$mode: |
The lock type. |
API Tags:
| Return: | True if succesful, false if not. |
| Abstract: | |
Redefined in descendants as:
Integer maxIdentifierLength(
)
|
|
Returns the maximum length an identifier (tablename, columnname, etc) may have
API Tags:
| Return: | The maximum identifier length |
Redefined in descendants as:
array metadata(
string
$table, [bool
$full = false]
)
|
|
Return the meta data of a certain table HIE GEBLEVEN
depending on $full, metadata returns the following values: -full is false (default): $result[]: [0]["table"] table name [0]["name"] field name [0]["type"] field type [0]["len"] field length [0]["flags"] field flags
-full is true: $result[]: ["num_fields"] number of metadata records [0]["table"] table name [0]["name"] field name [0]["type"] field type [0]["len"] field length [0]["flags"] field flags ["meta"][field name] index of field named "field name" The last one is used, if you have a field name, but no index.
Parameters:
|
string |
$table: |
the table name |
|
bool |
$full: |
all meta data or not |
API Tags:
Redefined in descendants as:
int nextid(
string
$sequence
)
|
|
Get the next sequence number of a certain sequence.
If the sequence does not exist, it is created automatically.
Parameters:
|
string |
$sequence: |
The sequence name |
API Tags:
| Return: | The next sequence value |
| Abstract: | |
Redefined in descendants as:
Retrieve the next record in the resultset.
API Tags:
| Return: | An array containing the record, or 0 if there are no more records to retrieve. |
| Abstract: | |
Redefined in descendants as:
void query(
String
$query, [int
$offset = -1], [int
$limit = -1]
)
|
|
Parse and execute a query.
If the query is a select query, the rows can be retrieved using the next_record() method.
Parameters:
|
String |
$query: |
The SQL query to execute |
|
int |
$offset: |
Retrieve the results starting at the specified record number. Pass -1 or 0 to start at the first record. |
|
int |
$limit: |
Indicates how many rows to retrieve. Pass -1 to retrieve all rows. |
API Tags:
Redefined in descendants as:
Get the current query statement resource id.
API Tags:
| Return: | Query statement resource id. |
Redefined in descendants as:
string quoteIdentifier(
string
$str
)
|
|
Quote Indentifier
Parameters:
Redefined in descendants as:
void rollback(
[string
$savepoint = ""]
)
|
|
Rollback the current transaction.
(If a savepoint is given to the given savepoint.)
Parameters:
|
string |
$savepoint: |
savepoint name |
API Tags:
Redefined in descendants as:
void savepoint(
string
$name
)
|
|
Set savepoint with the given name.
Parameters:
|
string |
$name: |
savepoint name |
API Tags:
Redefined in descendants as:
void setHaltOnError(
[Bool
$state = true]
)
|
|
Halt on error or not?
Parameters:
Redefined in descendants as:
void &setInstance(
string
$name,
&$db, object
$db
)
|
|
Replace the current instance of a named connection at runtime with a different connection. This is useful for example for replacing a named database instance with a mock object for testing purposes.
Parameters:
|
string |
$name: |
|
|
object |
$db: |
|
|
|
&$db: |
|
Redefined in descendants as:
void setSequenceValue(
string
$seqname, int
$value
)
|
|
Set database sequence value.
Parameters:
|
string |
$seqname: |
sequence name |
|
int |
$value: |
sequence value |
API Tags:
Redefined in descendants as:
void setUserError(
mixed
$errno
)
|
|
Define custom user error codes.
Error codes passed to this method will be treated as recoverable user errors.
Parameters:
|
mixed |
$errno: |
Vendor-dependent database error code |
Redefined in descendants as:
bool tableExists(
string
$tableName
)
|
|
This function checks the database for a table with the provide name
Parameters:
|
string |
$tableName: |
the table to find |
API Tags:
| Return: | true if found, false if not found |
Redefined in descendants as:
array tableMeta(
string
$table
)
|
|
Fetches table meta data from database
Parameters:
API Tags:
Redefined in descendants as:
array table_names(
[boolean
$includeViews = true]
)
|
|
Return the available table names
Parameters:
|
boolean |
$includeViews: |
include views? |
API Tags:
| Return: | with table names etc. |
Redefined in descendants as:
void toggleForeignKeys(
boolean
$enable
)
|
|
Enable/disable all foreign key constraints.
Parameters:
|
boolean |
$enable: |
enable/disable foreign keys? |
Redefined in descendants as:
Relieve all locks.
API Tags:
| Return: | True if succesful, false if not. |
| Abstract: | |
Redefined in descendants as:
String vendorDateFormat(
String
$format
)
|
|
Convert a php date() format specifier to a vendor specific format specifier.
The default implementation returns the format as used by many database vendors ('YYYYMMDD HH24:MI'). Databases that use different formatting, should override this method.
Note that currently, only the common specifiers Y, m, d, H, h, i and s are supported.
Parameters:
|
String |
$format: |
Format specifier. The format is compatible with php's date() function (http://www.php.net/date) |
API Tags:
| Return: | Vendor specific format specifier. |
Redefined in descendants as:
array _getTableMetaFromCache(
string
$table
)
|
|
If cached it'll return the table metadata from cache.
Parameters:
API Tags:
array _getTableMetaFromDb(
string
$table
)
|
|
Returns the tablemetadata directly from db
Parameters:
API Tags:
int _translateError(
mixed
$errno
)
|
|
Translate database-vendor dependent error messages into an ATK generic error code.
Derived classes should implement this method and translate their error codes.
Parameters:
|
mixed |
$errno: |
Vendor-dependent error code. |
API Tags:
| Return: | ATK error code |
| Access: | private |
Redefined in descendants as: