Loading Please wait...

zCDE Class Reference
[Common Database Essentials]

Inheritance diagram for zCDE:

Inheritance graph
[legend]
Collaboration diagram for zCDE:

Collaboration graph
[legend]

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 ( &$  obj  ) 

Converts an unIterable Object to an Iterable array.

Parameters:
$obj mixed
Returns:
array

Definition at line 67 of file zcde.php.

00067                             {
00068     if(is_array($obj))return $obj;
00069     return array($obj);
00070   }

zCDE::toUnIterable ( arr  ) 

Converts an Iterable array to unIterable Object [returns the First row if multiple Rows Exist].

Parameters:
$arr array
Returns:
mixed

Definition at line 77 of file zcde.php.

00077                              {
00078     if(!is_array($arr))return $arr;
00079     if(count($arr)==0)return false;
00080     foreach($arr as $obj)return $obj;
00081   }

zCDE::toObj ( arr  ) 

Converts an Array to stdClass Object.

Parameters:
$arr array

Definition at line 87 of file zcde.php.

References $val, and perror().

00087                       {
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   }

Here is the call graph for this function:

zCDE::toArray ( obj  ) 

Converts an Object to an Array.

Parameters:
$obj object

Definition at line 104 of file zcde.php.

References $val.

00104                         {
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   }

zCDE::dsnBuilder ( driver,
usr,
psw,
host,
db,
table,
port = null,
schema = null 
)

Builds a DSN.

Parameters:
$driver string
$usr string
$psw string
$host string
$db string
$table string
$port string Optional
$schema string Optional
Returns:
string

Definition at line 125 of file zcde.php.

00125                                                                                         {
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   }

zCDE::dsnExplode ( dsn  ) 

Explode a DNS into an Array.

Parameters:
$dsn string
Returns:
array

Definition at line 138 of file zcde.php.

References perror().

00138                            {
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   }

Here is the call graph for this function:

zCDE::createConn ( conAliasName,
drv,
database = null,
host = null,
user = null,
psw = null,
port = null 
)

Create a Connection File (returns false if file already exists).

Parameters:
$conAliasName string
$drv string
$database string
$host string Optional
$user string Optional
$psw string Optional
$port int Optional
Returns:
boolean

Definition at line 164 of file zcde.php.

00164                                                                                                          {
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   }

zCDE::deleteConn ( conAliasName  ) 

Delete a Connection File.

Parameters:
$connAliasName string
Returns:
boolean

Definition at line 176 of file zcde.php.

00176                                     {
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   }

zCDE::overWriteConn ( conAliasName,
drv,
database = null,
host = null,
user = null,
psw = null,
port = null 
)

Creates a Connection File (Over Writes if already exist).

Parameters:
$conAliasName string
$drv string
$database string
$host string Optional
$user string Optional
$psw string Optional
$port int Optional
Returns:
boolean

Definition at line 193 of file zcde.php.

00193                                                                                                             {
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   }

zCDE::parseConn ( conAliasName  ) 

Parse the Connection file into an array.

Parameters:
$conAliasName string
Returns:
array

Definition at line 204 of file zcde.php.

00204                                    {
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   }


The documentation for this class was generated from the following file:

Generated on Mon Oct 27 23:53:21 2008 for zigmoyd.kdevelop by doxygen 1.5.6