Loading Please wait...

zDbAccess Class Reference
[Custom Database Access without Magic Methods]

Inheritance diagram for zDbAccess:

Inheritance graph
[legend]
Collaboration diagram for zDbAccess:

Collaboration graph
[legend]

Public Member Functions

 zDbAccess ($connAlias, $tableName)
 __construct ($connAlias, $tableName)
 Constructs Table level Objects.

Private Member Functions

 colList ($conAlias, $driver)
 Bind's Proper driver, and connects through it.

Detailed Description

dbAccess Class builds a table Object dynamically. without using static ORM Maps. it uses teh real column names as the column alias name. and as there is no orm map assiciated wit it it doesn't uses any validation filters. you need to load dbAccess module to use it.
You cant use any magic method that comes from zOrm_magic like findCol() or findColByOp() etc.. However yo can use all non-magic methods that comes from zOrm_nomagic and its parents.
you need to pass a table name with which you want to connect and pass the connection name e.g. Connection file name by using that it will connect.
you can even create dynamic Connection files on the fly. take a look at the zCDE Class/Module. If you need magic-method support use zDynOrm Class Instead.
  $this->load->module('dbAccess');
  //code this in your Controller to load the module
  //You can also code load_module('dbAccess');
  $stdObj = new zDbAccess('conAliasName', 'student');
  //$stdObj = new zDbAccess('conAliasName', 'tableName');
  $stdObj->find('std_name');//$stdObj->find('col_name');

Definition at line 65 of file dbaccess.php.


Constructor & Destructor Documentation

zDbAccess::__construct ( connAlias,
tableName 
)

Constructs Table level Objects.

Parameters:
$connAlias string Connection file name
$tableName string Table name to which to connect.

Definition at line 75 of file dbaccess.php.

References zOrm_core::$connAlias, colList(), zOrm_core::init(), and perror().

00075                                               {
00076     $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$connAlias.".con.ini.php";
00077     if(!file_exists($path)){
00078       perror('<code>zigmoyd.dynamicOrm.init</code><br />Failed to parse the connection file '.$connAlias.' as  the file doesn\'t exist');
00079       exit;
00080     }
00081     if(!defined('ZIGORM_Q_SELECT')){define('ZIGORM_Q_SELECT', 's');}
00082     if(!defined('ZIGORM_Q_INSERT')){define('ZIGORM_Q_INSERT', 'i');}
00083     if(!defined('ZIGORM_Q_UPDATE')){define('ZIGORM_Q_UPDATE', 'u');}
00084     if(!defined('ZIGORM_Q_REMOVE')){define('ZIGORM_Q_REMOVE', 'r');}
00085     if(!defined('ZIGORM_Q_SQL')){define('ZIGORM_Q_SQL', 'q');}
00086     if(!defined('ZIGORM_Q_TRUNCATE')){define('ZIGORM_Q_TRUNCATE', 't');}
00087     if(!defined('ZIGORM_NO_FLUSH')){define('ZIGORM_NO_FLUSH', false);}
00088     if(!defined('ZIGORM_FLUSH')){define('ZIGORM_FLUSH', true);}
00089     if(!defined('ZIGORM_NO_QUOTE'))define('ZIGORM_NO_QUOTE', false);
00090     if(!defined('ZIGORM_QUOTE'))define('ZIGORM_QUOTE', true);
00091     if(!defined('ZIGORM_Q_JOIN')){define('ZIGORM_Q_JOIN', 'j');}
00092     if(!defined('ZIGORM_Q_AUTOJOIN')){define('ZIGORM_Q_AUTOJOIN', 'aj');}
00093     if(!defined('ZIGORM_JOIN_CROSS'))define('ZIGORM_JOIN_CROSS', 'jc');
00094     if(!defined('ZIGORM_JOIN_LEFT'))define('ZIGORM_JOIN_LEFT', 'jl');
00095     if(!defined('ZIGORM_JOIN_RIGHT'))define('ZIGORM_JOIN_RIGHT', 'jr');
00096     if(!defined('ZIGORM_JOIN_FULL'))define('ZIGORM_JOIN_FULL', 'jf');
00097     if(!defined('ZIGORM_JOIN_INNER'))define('ZIGORM_JOIN_INNER', 'ji');
00098     if(!defined('ZIGORM_JOIN_NATURAL'))define('ZIGORM_JOIN_NATURAL', 'jn');
00099     if(!defined('ZIGORM_OP_EQUALS'))define('ZIGORM_OP_EQUALS', '=');
00100     if(!defined('ZIGORM_OP_GREATER'))define('ZIGORM_OP_GREATER', '>');
00101     if(!defined('ZIGORM_OP_LESS'))define('ZIGORM_OP_LESS', '<');
00102     if(!defined('ZIGORM_OP_GREATER_EQUALS'))define('ZIGORM_OP_GREATER_EQUALS', '>=');
00103     if(!defined('ZIGORM_OP_LESS_EQUALS'))define('ZIGORM_OP_LESS_EQUALS', '<=');
00104     if(!defined('ZIGORM_OP_NOT_EQUALS'))define('ZIGORM_OP_NOT_EQUALS', '<>');
00105     $conData = parse_ini_file($path);
00106     $this->realTableName = $tableName;
00107     $this->tableAlias = $tableName;
00108     $this->connAlias = $connAlias;
00109     $this->__struct = new stdClass();
00110     $this->__struct->alias = $tableName;
00111     $this->__struct->Attributes = array();
00112     foreach($this->colList($connAlias, $conData['driver']) as $colName){
00113       $this->__struct->Attributes[$colName] = new stdClass();
00114       $this->__struct->Attributes[$colName]->alias = $colName;
00115       $this->__struct->Attributes[$colName]->permission = 'writable';
00116     }
00117     $this->init();
00118   }

Here is the call graph for this function:


Member Function Documentation

zDbAccess::zDbAccess ( connAlias,
tableName 
)

Definition at line 66 of file dbaccess.php.

References zOrm_core::$connAlias, and zCore::__construct().

00066                                             {
00067     $this->__construct($connAlias, $tableName);
00068   }

Here is the call graph for this function:

zDbAccess::colList ( conAlias,
driver 
) [private]

Bind's Proper driver, and connects through it.

For internal use only.

Definition at line 124 of file dbaccess.php.

References $__ZigOrm, zOrm_core::$driver, $GLOBALS, connections, zLogger::debug(), zLogger::error(), and perror().

Referenced by __construct().

00124                                       {
00125     switch(trim($driver)){
00126       case 'mysql':
00127           zLogger::debug("Using Orm driver mysql", 'orm.'.$this->realTableName);
00128           include_once(ZIGROOT.DRS.MOD_KEY_NAME_EXPLICIT.DRS.'orm'.DRS.'driver'.DRS.'mysql.php');
00129           $GLOBALS['__zigmoyd__Orm_drv'] = new OrmDriver_mysql();
00130           $GLOBALS['__zigmoyd__Orm_drv']->connAlias($conAlias);
00131           if(!$GLOBALS['__zigmoyd__Orm_drv']->connect()){
00132             perror("<code>zigmoyd.dynamicOrm.core.execute</code><br />Failed To Connect $this->connAlias");
00133             return false;
00134           }
00135           return $GLOBALS['__zigmoyd__Orm_drv']->listCols($this->realTableName);
00136         break;
00137       default:
00138         zLogger::error("Using Invalid Driver ".$__ZigOrm->connections[$this->conn_alias]->driver, 'orm.'.$this->__table_name);
00139         perror('Invalid Driver '.$__ZigOrm->connections[$this->conn_alias]->driver." seleced");
00140     }
00141   }

Here is the call graph for this function:


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

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