$mConnectionResource
$mConnectionResource : resource
Resource created by the database connection
An implementation of the abstraction of the Oracle database engine
__construct(string $dbHost, string $dbUser, mixed $dbPass, string $dbName)
Class constructor.
Setup parameters through AiCommon and access the database through that class' instance of this class
| string | $dbHost | The database host name |
| string | $dbUser | The database username |
| mixed | $dbPass | The database password |
| string | $dbName | The name of the database |
query(string $query, string $file, int $line) : resource
Perform a query of the database.
This does not assume that strings have been escaped, so be sure to escape them.
Use the PHP macros FILE and LINE for the 2nd and 3rd parameters.
| string | $query | The query to perform |
| string | $file | The file making the query |
| int | $line | The line number in the querying file |
blockInjection(string $string) : string
Returns any part of a query before a semi-colon
If there is an attempt of an injection attack, or if your string input legitimately has semicolons, this is likely to cause truncated input.
If your input may contain semicolons, be sure that you trust the source before allowing it to perfom a query.
| string | $string | The string to de-inject |
fetchArray(resource $result) : array
Fetch a row form the database and return it as an indexed array and an associative array with field names as indexes.
For consistency, returned keys are cast to lower case
| resource | $result | The conenction resource returned by a query |
fieldName(resource $result, int $columnOffset) : string
Get the name of a field at the given offset
To be consistent with the "normal" abstractions, field offset is converted to 0-based, whereas oci_field_name is oddly 1-based Results are also cast to lower case
| resource | $result | The conenction resource returned by a query |
| int | $columnOffset | The offset of the requested column (0 is the first column) |
fieldType(resource $result, int $columnOffset) : string
The type of field at the given offset
To be consistent with the "normal" abstractions, field offset is converted to 0-based, whereas oci_field_name is oddly 1-based
| resource | $result | The conenction resource returned by a query |
| int | $columnOffset | The offset of the requested column (0 is the first column) |
simpleFieldType(resource $result, int $columnOffset) : string
A uniform type of field at the given offset.
Returns a string that represents a simplified field type for consistency across DBMS'
We don't check every field type. This has been written for the field types that APP(ideas) uses commonly. It will probably need modification to suit the needs of others.
This globs a lot of different types together. You may need to make them more fine-grained
| resource | $result | The conenction resource returned by a query |
| int | $columnOffset | The offset of the requested column (0 is the first column) |
fixBoolean(string $booleanValue) : bool
Convert a database-formatted boolean value into something consistent with PHP
For Oracle, this assumes that the boolean field is an int that will contain either 1 or 0
| string | $booleanValue | A boolean value retrieved from a database query |
insertBlank(string $tableName, string $fieldName, mixed $requiredFields) : int
Inserts a blank record into the requested table and returns the value of the surrogate key of the new record.
This allows us to use a "modify" method for saving new data rather than separate "add" and "modify"
If one of your "requiredFields" is a string, you must enclose it in apostrophes on input
| string | $tableName | The name of the table into which we are inserting |
| string | $fieldName | The name of the field into which we are inserting |
| mixed | $requiredFields | An array of other fields and values that must not be null on a new record insert |
beginTransaction(string $file, int $line) : void
Begins a database transaction if supported by the DBMS
There is no explicit "transaction begin" in OCI8. Transactions are commited either automatically or through oci_commit();
| string | $file | The file making the query. Leave empty to report the DB connector file name. |
| int | $line | The line number in the querying file. Leave empty to report the DB connector line number. |
endTransaction(string $file, int $line) : void
Ends (commits) a database transaction if supported by the DBMS
| string | $file | The file making the query. Leave empty to report the DB connector file name. |
| int | $line | The line number in the querying file. Leave empty to report the DB connector line number. |
getCurrentTimestamp(string $format) : string
Retrieves a value that can be inserted into the database as a date or timestamp indicating the current date and/or time
For oracle, with the exception of the default option, you will probably need to wrap the results in a TO_DATE function
The default return form is "timestamp without timezone"
| string | $format | The format of the string to return. One of 'database' 'epoch' or a PHP date() format. The default is 'database' |
updateLob(string $tableName, string $pkColumn, mixed $pkValue, string $lobColumn, mixed $newValue, bool $isClob) : void
Updates a BLOB or CLOB by primary key.
| string | $tableName | The name of the table |
| string | $pkColumn | Primary key column name |
| mixed | $pkValue | The value of the PK |
| string | $lobColumn | The column being updated |
| mixed | $newValue | The value to update |
| bool | $isClob | BLOB if FALSE, CLOB if true |