Class: I2CE Util: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
This article desrcibes the class '''I2CE_Util''' | This article desrcibes the class '''I2CE_Util'''. | ||
It is contained in the module [[iHRIS Module List#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE] | It is contained in the module [[iHRIS Module List#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE] | ||
Line 18: | Line 18: | ||
Convers a sql like statement to a regular expression | Convers a sql like statement to a regular expression | ||
*Signature: static public function convertLikeToRegExp($like,$escape) | *Signature: static public function convertLikeToRegExp($like,$escape) | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.string.php string] $like | * [http://www.php.net/manual/en/language.types.string.php string ] $like | ||
* [http://www.php.net/manual/en/language.types.string.php string] $escape<br/>The escape character. Defaults to \' | * [http://www.php.net/manual/en/language.types.string.php string ] $escape<br/>The escape character. Defaults to \' | ||
**Default Value: '\\' | **Default Value: '\\' | ||
===explodeAndExecuteSQLQueries()=== | ===explodeAndExecuteSQLQueries()=== | ||
Line 27: | Line 27: | ||
@param MDB2 connection $db | @param MDB2 connection $db | ||
*Signature: static public function explodeAndExecuteSQLQueries($sql,$db,$transact,$delimiter) | *Signature: static public function explodeAndExecuteSQLQueries($sql,$db,$transact,$delimiter) | ||
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean] true on sucess or false | *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] true on sucess or false | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.string.php string] $sql<br/>a nuch of sql queries | * [http://www.php.net/manual/en/language.types.string.php string ] $sql<br/>a nuch of sql queries | ||
*$db | *$db | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $transact<br/>defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of a savepoint to rollback to/release | * [http://www.php.net/manual/en/language.types.boolean.php boolean ] $transact<br/>defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of a savepoint to rollback to/release | ||
**Default Value: true | **Default Value: true | ||
* [http://www.php.net/manual/en/language.types.string.php string] $delimiter<br/>Defaults to ';'. Needs to be exactly one character | * [http://www.php.net/manual/en/language.types.string.php string ] $delimiter<br/>Defaults to ';'. Needs to be exactly one character | ||
**Default Value: ';' | **Default Value: ';' | ||
===flattenVariables()=== | ===flattenVariables()=== | ||
Line 40: | Line 40: | ||
*Signature: static public function flattenVariables($vars,$flat,$encode,$skip_empty,$prefix) | *Signature: static public function flattenVariables($vars,$flat,$encode,$skip_empty,$prefix) | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.array.php array] $vars<br/>the variables to flatten. | * [http://www.php.net/manual/en/language.types.array.php array ] $vars<br/>the variables to flatten. | ||
* [http://www.php.net/manual/en/language.types.array.php array] &$flat<br/>The array to store the falttened variables in | * [http://www.php.net/manual/en/language.types.array.php array ] &$flat<br/>The array to store the falttened variables in | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $encode<br/>Set to true (default) if we should urlencode the values | * [http://www.php.net/manual/en/language.types.boolean.php boolean ] $encode<br/>Set to true (default) if we should urlencode the values | ||
**Default Value: true | **Default Value: true | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $skip_empty<br/>Set to true (default) skip empty values | * [http://www.php.net/manual/en/language.types.boolean.php boolean ] $skip_empty<br/>Set to true (default) skip empty values | ||
**Default Value: true | **Default Value: true | ||
* [http://www.php.net/manual/en/language.types.string.php string] $prefix<br/>Defaults to ''; | * [http://www.php.net/manual/en/language.types.string.php string ] $prefix<br/>Defaults to ''; | ||
**Default Value: '' | **Default Value: '' | ||
===merge_recursive()=== | ===merge_recursive()=== | ||
Line 56: | Line 56: | ||
*Signature: static public function merge_recursive($a,$b,$addNew,$addEmpty) | *Signature: static public function merge_recursive($a,$b,$addNew,$addEmpty) | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.array.php array] &$a<br/>the array to merge into | * [http://www.php.net/manual/en/language.types.array.php array ] &$a<br/>the array to merge into | ||
* [http://www.php.net/manual/en/language.types.array.php array] $b<br/>the array to merge from | * [http://www.php.net/manual/en/language.types.array.php array ] $b<br/>the array to merge from | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $addNew<br/>Defaults to true. If false, we do not add new keys | * [http://www.php.net/manual/en/language.types.boolean.php boolean ] $addNew<br/>Defaults to true. If false, we do not add new keys | ||
**Default Value: true | **Default Value: true | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean] $addEmpty<br/>Defaults to true. If false, we do not add empty values | * [http://www.php.net/manual/en/language.types.boolean.php boolean ] $addEmpty<br/>Defaults to true. If false, we do not add empty values | ||
**Default Value: true | **Default Value: true | ||
===runSQLScript()=== | ===runSQLScript()=== | ||
Line 68: | Line 68: | ||
it will use whatever database is refered to by the MDB2::singleton() | it will use whatever database is refered to by the MDB2::singleton() | ||
*Signature: static public function runSQLScript($file,$database,$transact,$dsn,$delimiter) | *Signature: static public function runSQLScript($file,$database,$transact,$dsn,$delimiter) | ||
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean] -- true on sucess, false on failure | *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] -- true on sucess, false on failure | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.string.php string] $file<br/>The SQL file to execute -- it must lie in the fileSearch's SQL category | * [http://www.php.net/manual/en/language.types.string.php string ] $file<br/>The SQL file to execute -- it must lie in the fileSearch's SQL category | ||
* [http://www.php.net/manual/en/language.types.string.php string] $database<br/>If non-null it will connect to the named database. | * [http://www.php.net/manual/en/language.types.string.php string ] $database<br/>If non-null it will connect to the named database. | ||
**Default Value: null | **Default Value: null | ||
* [http://www.php.net/manual/en/language.pseudo-types.php mixed] $transact<br/>defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of | * [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $transact<br/>defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of | ||
**Default Value: true | **Default Value: true | ||
* [http://www.php.net/manual/en/language.types.string.php string] $dsn<br/>An option DSN to connect on. If set $database is ignored. | * [http://www.php.net/manual/en/language.types.string.php string ] $dsn<br/>An option DSN to connect on. If set $database is ignored. | ||
**Default Value: null | **Default Value: null | ||
* [http://www.php.net/manual/en/language.types.string.php string] $delimiter<br/>Defaults to ';' Needs to be exactly one character | * [http://www.php.net/manual/en/language.types.string.php string ] $delimiter<br/>Defaults to ';' Needs to be exactly one character | ||
**Default Value: ';' | **Default Value: ';' | ||
===transformVariables()=== | ===transformVariables()=== | ||
Transforms an array of variables with keys of the form 'key1:key2:key3' into a nested array ['key1']['key2']['key3'] | Transforms an array of variables with keys of the form 'key1:key2:key3' into a nested array ['key1']['key2']['key3'] | ||
*Signature: static public function transformVariables($vars) | *Signature: static public function transformVariables($vars) | ||
*Returns: [http://www.php.net/manual/en/language.types.array.php array] | *Returns: [http://www.php.net/manual/en/language.types.array.php array ] | ||
Parameters: | Parameters: | ||
* [http://www.php.net/manual/en/language.types.array.php array] $vars | * [http://www.php.net/manual/en/language.types.array.php array ] $vars | ||
[[Category:Class Documentation]] | [[Category:Class Documentation]] |
Revision as of 21:25, 16 October 2009
This article desrcibes the class I2CE_Util. It is contained in the module I2CE in the package I2CE
The class is defined in the file: lib/I2CE_Util.php
@subpackage Core I2CE_Util @todo Better documentation
- Author: Carl Leitner <litlfred@ibiblio.org>
Methods
array_unique()
array unique which respects multi-dimensional arrays from: the link http://us.php.net/manual/en/function.array-unique.php#84750 sda
- Signature: static public function array_unique($arr)
Parameters:
- $arr
convertLikeToRegExp()
Convers a sql like statement to a regular expression
- Signature: static public function convertLikeToRegExp($like,$escape)
- Returns: string
Parameters:
explodeAndExecuteSQLQueries()
Explode and execute a @param MDB2 connection $db
- Signature: static public function explodeAndExecuteSQLQueries($sql,$db,$transact,$delimiter)
- Returns: boolean true on sucess or false
Parameters:
- string $sql
a nuch of sql queries - $db
- boolean $transact
defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of a savepoint to rollback to/release- Default Value: true
- string $delimiter
Defaults to ';'. Needs to be exactly one character- Default Value: ';'
flattenVariables()
Flatten variables. Transforms an array of variables of a nested array ['key1']['key2']['key3'] to an array with keys of the form 'key1:key2:key3'
- Signature: static public function flattenVariables($vars,$flat,$encode,$skip_empty,$prefix)
Parameters:
- array $vars
the variables to flatten. - array &$flat
The array to store the falttened variables in - boolean $encode
Set to true (default) if we should urlencode the values- Default Value: true
- boolean $skip_empty
Set to true (default) skip empty values- Default Value: true
- string $prefix
Defaults to ;- Default Value:
merge_recursive()
Performs a recursive array merge which _overwrites_ values, not appends them ( the behaviour of array_merge_recursive). Warning: This is not a symmetric operation. Any multi-index that exists in $a and in $b will result that the value in $a will be overwritten by the value in $a
- Signature: static public function merge_recursive($a,$b,$addNew,$addEmpty)
Parameters:
- array &$a
the array to merge into - array $b
the array to merge from - boolean $addNew
Defaults to true. If false, we do not add new keys- Default Value: true
- boolean $addEmpty
Defaults to true. If false, we do not add empty values- Default Value: true
runSQLScript()
Executes a script (this is ensured by addinging it to a <path name='sql'> node in the configuration XML a save point to use (assumes you are already in a transaction) it will use whatever database is refered to by the MDB2::singleton()
- Signature: static public function runSQLScript($file,$database,$transact,$dsn,$delimiter)
- Returns: boolean -- true on sucess, false on failure
Parameters:
- string $file
The SQL file to execute -- it must lie in the fileSearch's SQL category - string $database
If non-null it will connect to the named database.- Default Value: null
- mixed $transact
defaults to true meaning that the whole script is executed in a transaction. If a string, it is the name of- Default Value: true
- string $dsn
An option DSN to connect on. If set $database is ignored.- Default Value: null
- string $delimiter
Defaults to ';' Needs to be exactly one character- Default Value: ';'
transformVariables()
Transforms an array of variables with keys of the form 'key1:key2:key3' into a nested array ['key1']['key2']['key3']
- Signature: static public function transformVariables($vars)
- Returns: array
Parameters:
- array $vars