Public Member Functions | |
zQuery ($conAlias) | |
__construct ($conAlias) | |
Instanciates teh zQuery Engine. | |
exec ($sqlQuery) | |
Executes The SQL Query. | |
export () | |
Exports the Result Set as an array (Numarically Indexed by Row Number). | |
numRows () | |
Number of rows in the result set. | |
affectedRows () | |
Rows affected by the Query. | |
Data Fields | |
$handle | |
$conAlias | |
$num_rows | |
$affected_rows | |
$raw_exported | |
$lex | |
Private Member Functions | |
init () | |
(Re)Initialize |
$q = new zQuery('conAliasName'); //Pass the connection file Name against which the query will be executed. $q->exec('select * from student'); $rowSet = $q->export();//Now $rowSet Represents the Result Returned. $n = $q->numRows() $q->exec("insert into student values(1, 'foo', 'bar')"); $n = $q->affectedRows();
Definition at line 52 of file zquery.php.
zQuery::__construct | ( | $ | conAlias | ) |
Instanciates teh zQuery Engine.
$conAlias | string |
Definition at line 68 of file zquery.php.
References $__ZigOrm, $conAlias, connections, zLogger::debug(), zLogger::error(), and perror().
00068 { 00069 global $__ZigOrm; 00070 if(!defined('ZIGORM_Q_SELECT')){define('ZIGORM_Q_SELECT', 's');} 00071 if(!defined('ZIGORM_Q_INSERT')){define('ZIGORM_Q_INSERT', 'i');} 00072 if(!defined('ZIGORM_Q_UPDATE')){define('ZIGORM_Q_UPDATE', 'u');} 00073 if(!defined('ZIGORM_Q_REMOVE')){define('ZIGORM_Q_REMOVE', 'r');} 00074 if(!defined('ZIGORM_Q_SQL')){define('ZIGORM_Q_SQL', 'q');} 00075 if(!defined('ZIGORM_Q_TRUNCATE')){define('ZIGORM_Q_TRUNCATE', 't');} 00076 if(!defined('ZIGORM_NO_FLUSH')){define('ZIGORM_NO_FLUSH', false);} 00077 if(!defined('ZIGORM_FLUSH')){define('ZIGORM_FLUSH', true);} 00078 if(!defined('ZIGORM_NO_QUOTE'))define('ZIGORM_NO_QUOTE', false); 00079 if(!defined('ZIGORM_QUOTE'))define('ZIGORM_QUOTE', true); 00080 if(!defined('ZIGORM_Q_JOIN')){define('ZIGORM_Q_JOIN', 'j');} 00081 if(!defined('ZIGORM_Q_AUTOJOIN')){define('ZIGORM_Q_AUTOJOIN', 'aj');} 00082 if(!defined('ZIGORM_JOIN_CROSS'))define('ZIGORM_JOIN_CROSS', 'jc'); 00083 if(!defined('ZIGORM_JOIN_LEFT'))define('ZIGORM_JOIN_LEFT', 'jl'); 00084 if(!defined('ZIGORM_JOIN_RIGHT'))define('ZIGORM_JOIN_RIGHT', 'jr'); 00085 if(!defined('ZIGORM_JOIN_FULL'))define('ZIGORM_JOIN_FULL', 'jf'); 00086 if(!defined('ZIGORM_JOIN_INNER'))define('ZIGORM_JOIN_INNER', 'ji'); 00087 if(!defined('ZIGORM_JOIN_NATURAL'))define('ZIGORM_JOIN_NATURAL', 'jn'); 00088 if(!defined('ZIGORM_OP_EQUALS'))define('ZIGORM_OP_EQUALS', '='); 00089 if(!defined('ZIGORM_OP_GREATER'))define('ZIGORM_OP_GREATER', '>'); 00090 if(!defined('ZIGORM_OP_LESS'))define('ZIGORM_OP_LESS', '<'); 00091 if(!defined('ZIGORM_OP_GREATER_EQUALS'))define('ZIGORM_OP_GREATER_EQUALS', '>='); 00092 if(!defined('ZIGORM_OP_LESS_EQUALS'))define('ZIGORM_OP_LESS_EQUALS', '<='); 00093 if(!defined('ZIGORM_OP_NOT_EQUALS'))define('ZIGORM_OP_NOT_EQUALS', '<>'); 00094 if(!strlen($this->conAlias))$this->conAlias = $conAlias; 00095 $path = ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.ZIGSETTINGSDIR.DRS.Z_DIR_ETC_CONF.DRS.$conAlias.".con.ini.php"; 00096 if(!file_exists($path)){ 00097 perror('<code>zigmoyd.dynamicOrm.init</code><br />Failed to parse the connection file '.$conAlias.' as the file doesn\'t exist'); 00098 exit; 00099 } 00100 $conData = parse_ini_file($path); 00101 if(!is_object($this->handle)){//-- Experimental Line (If else Conditional Integreety) 00102 switch(trim($conData['driver'])){ 00103 case 'mysql': 00104 zLogger::debug("Using Orm driver mysql", 'orm'); 00105 include_once(ZIGROOT.DRS.MOD_KEY_NAME_EXPLICIT.DRS.'orm'.DRS.'driver'.DRS.'mysql.php'); 00106 $this->handle = new OrmDriver_mysql(); 00107 break; 00108 default: 00109 zLogger::error("Using Invalid Driver ".$__ZigOrm->connections[$this->conAlias]->driver, 'orm.'); 00110 perror('Invalid Driver '.$__ZigOrm->connections[$this->conAlias]->driver." seleced"); 00111 } 00112 } 00113 }
zQuery::zQuery | ( | $ | conAlias | ) |
Definition at line 60 of file zquery.php.
References $conAlias, and zCore::__construct().
00060 { 00061 $this->__construct($conAlias); 00062 }
zQuery::init | ( | ) | [private] |
(Re)Initialize
For internal use only.
Definition at line 119 of file zquery.php.
Referenced by exec().
00119 { 00120 $this->num_rows = null; 00121 $this->affected_rows = null; 00122 $this->raw_exported = null; 00123 }
zQuery::exec | ( | $ | sqlQuery | ) |
Executes The SQL Query.
$sqlQuery | string |
Definition at line 130 of file zquery.php.
References init().
00130 { 00131 $this->init(); 00132 $this->handle->connAlias($this->conAlias); 00133 $this->handle->setCaller(&$this); 00134 $this->handle->sql = $sqlQuery; 00135 $this->handle->connect(); 00136 $this->handle->qType(ZIGORM_Q_SQL); 00137 $ret = $this->handle->execute(); 00138 $this->num_rows = $this->handle->numRows(); 00139 $this->affected_rows = $this->handle->affectedRows(); 00140 $this->raw_exported = $this->handle->exportRaw(); 00141 return $ret; 00142 }
zQuery::export | ( | ) |
Exports the Result Set as an array (Numarically Indexed by Row Number).
Definition at line 148 of file zquery.php.
00148 { 00149 $rowSetClassName = get_class($this).'RowSet'; 00150 $ret = array(); 00151 if(!is_array($this->raw_exported))return false; 00152 foreach($this->raw_exported as $rowId => $rowObj){ 00153 $indx = $rowId; 00154 $ret[$indx] = new $rowSetClassName; 00155 $ret[$indx]->colList = $rowObj->colList; 00156 //$ret[$indx]->handle = &$this;//for PHP5 00157 unset($rowObj); 00158 } 00159 return $ret; 00160 }
zQuery::numRows | ( | ) |
zQuery::affectedRows | ( | ) |
zQuery::$handle |
Definition at line 53 of file zquery.php.
zQuery::$conAlias |
zQuery::$num_rows |
Definition at line 55 of file zquery.php.
zQuery::$affected_rows |
Definition at line 56 of file zquery.php.
zQuery::$raw_exported |
Definition at line 57 of file zquery.php.
zQuery::$lex |
Definition at line 58 of file zquery.php.