Formatting output Plese Wait...
|
Public Member Functions |
| toIterable (&$obj) |
| Converts an unIterable Object to an Iterable array.
|
| toUnIterable ($arr) |
| Converts an Iterable array to unIterable Object [returns the First row if multiple Rows Exist].
|
| toObj ($arr) |
| Converts an Array to stdClass Object.
|
| toArray ($obj) |
| Converts an Object to an Array.
|
| dsnBuilder ($driver, $usr, $psw, $host, $db, $table, $port=null, $schema=null) |
| Builds a DSN.
|
| dsnExplode ($dsn) |
| Explode a DNS into an Array.
|
| createConn ($conAliasName, $drv, $database=null, $host=null, $user=null, $psw=null, $port=null) |
| Create a Connection File (returns false if file already exists).
|
| deleteConn ($conAliasName) |
| Delete a Connection File.
|
| overWriteConn ($conAliasName, $drv, $database=null, $host=null, $user=null, $psw=null, $port=null) |
| Creates a Connection File (Over Writes if already exist).
|
| parseConn ($conAliasName) |
| Parse the Connection file into an array.
|
Detailed Description
Common database essential.
Definition at line 60 of file zcde.php.
Member Function Documentation
zCDE::toIterable( mixed $obj )
Converts an unIterable Object to an Iterable array.
- Parameters:
-
- Returns:
- array
Definition at line 67 of file zcde.php.
Show Source00067 {
00068 if(is_array($obj))return $obj;
00069 return array($obj);
00070 }
Top
zCDE::toUnIterable( array $arr )
Converts an Iterable array to unIterable Object [returns the First row if multiple Rows Exist].
- Parameters:
-
- Returns:
- mixed
Definition at line 77 of file zcde.php.
Show Source00077 {
00078 if(!is_array($arr))return $arr;
00079 if(count($arr)==0)return false;
00080 foreach($arr as $obj)return $obj;
00081 }
Top
zCDE::toObj( array $arr )
Converts an Array to stdClass Object.
- Parameters:
-
Definition at line 87 of file zcde.php.
References $val, and perror().
Show Source00087 {
00088 if(!is_array($arr))return $arr;
00089 $retObj = new stdClass();
00090 foreach($arr as $key => $val){
00091 if(ctype_digit($key)){
00092 perror("<code>zigmoyd.cde</code><br />Your Array must not be numarically Indexed to get converted to an object");
00093 }else{
00094 $retObj->{$key} = zCDE::toObj($val);
00095 }
00096 }
00097 return $retObj;
00098 }
Top
zCDE::toArray( object $obj )
Converts an Object to an Array.
- Parameters:
-
Definition at line 104 of file zcde.php.
References $val.
Show Source00104 {
00105 if(!is_object($obj))return $obj;
00106 $ret = array();
00107 foreach($obj as $key => $val){
00108 $ret[$key] = zCDE::toArray($val);
00109 }
00110 return $ret;
00111 }
Top
zCDE::dsnBuilder( string $driver, string $usr, string $psw, string $host, string $db, string $table, string $port = null
, string $schema = null
)
Builds a DSN.
- Parameters:
-
| $driver | |
| $usr | |
| $psw | |
| $host | |
| $db | |
| $table | |
| $port | Optional |
| $schema | Optional |
- Returns:
- string
Definition at line 125 of file zcde.php.
Show Source00125 {
00126 if($port)$portStr = ":$port";
00127 else $portStr = "";
00128 if($schema)$tableStr = "$schema.$table";
00129 else $tableStr = $table;
00130 return "$driver://$usr:$psw@$host$portStr/$db/$tableStr";
00131 }
Top
zCDE::dsnExplode( string $dsn )
Explode a DNS into an Array.
- Parameters:
-
- Returns:
- array
Definition at line 138 of file zcde.php.
References perror().
Show Source00138 {
00139 if(preg_match('~(?P<driver>\w+)://(?P<usr>\w+):(?P<psw>\w+)@(?P<host>\w+)(?::(?P<port>\d+))?/(?P<db>\w+)/(?P<schema>\w+)(?:\.(?P<table>\w+))?~', $dsn, $m) < 1){
00140 perror('<code>zigmoyd.cde.dnsExplode</code><br />Failed to Parse as Invalid DNS Specified');
00141 return false;
00142 }
00143 for($i = 0;$i<count($m);++$i){
00144 if(isset($m[$i]))unset($m[$i]);
00145 }
00146 if(!isset($m['table'])){
00147 $m['table'] = $m['schema'];
00148 unset($m['schema']);
00149 }
00150 return $m;
00151 }
Top
zCDE::createConn( string $conAliasName, string $drv, string $database = null
, string $host = null
, string $user = null
, string $psw = null
, int $port = null
)
Create a Connection File (returns false if file already exists).
- Parameters:
-
| $conAliasName | |
| $drv | |
| $database | |
| $host | Optional |
| $user | Optional |
| $psw | Optional |
| $port | Optional |
- Returns:
- boolean
Definition at line 164 of file zcde.php.
Show Source00164 {
00165 $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$conAliasName.".con.ini.php";
00166 if(file_exists($path))return false;
00167 $iniStr = "driver=\"$drv\"\ndatabase=\"$database\"\nhost=\"$host\"\nuser=\"$user\"\npsw=\"$psw\"\nport=\"$port\"";
00168 return file_put_contents($path, $iniStr);
00169 }
Top
zCDE::deleteConn( int $conAliasName )
Delete a Connection File.
- Parameters:
-
- Returns:
- boolean
Definition at line 176 of file zcde.php.
Show Source00176 {
00177 $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$conAliasName.".con.ini.php";
00178 if(!file_exists($path))return false;
00179 return unlink($path);
00180 }
Top
zCDE::overWriteConn( string $conAliasName, string $drv, string $database = null
, string $host = null
, string $user = null
, string $psw = null
, int $port = null
)
Creates a Connection File (Over Writes if already exist).
- Parameters:
-
| $conAliasName | |
| $drv | |
| $database | |
| $host | Optional |
| $user | Optional |
| $psw | Optional |
| $port | Optional |
- Returns:
- boolean
Definition at line 193 of file zcde.php.
Show Source00193 {
00194 $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$conAliasName.".con.ini.php";
00195 $iniStr = "driver=\"$drv\"\ndatabase=\"$database\"\nhost=\"$host\"\nuser=\"$user\"\npsw=\"$psw\"\nport=\"$port\"";
00196 return file_put_contents($path, $iniStr);
00197 }
Top
zCDE::parseConn( string $conAliasName )
Parse the Connection file into an array.
- Parameters:
-
- Returns:
- array
Definition at line 204 of file zcde.php.
Show Source00204 {
00205 $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$conAliasName.".con.ini.php";
00206 if(file_exists($path))return false;
00207 return parse_ini_file($path);
00208 }
Top
The documentation for this class was generated from the following file: