Public Member Functions | |
identifyBy ($colAliasName, $val, $op='=', $mandatory=true) | |
set ($colAliasName, $Value, $quote=true) | |
fetch ($colAliasName, $flag=true) | |
fetchAs ($colAliasName, $virtualAliasName) | |
find ($colAliasName, $indexKey=null) | |
findBy ($colAliasName, $searchCol, $val, $op=null, $indexCol=null) | |
isPk ($colAliasName) | |
join ($cleanUp=true) | |
forceJoin ($foreignTableName, $foreignCol, $srcCol) | |
innerJoin ($foreignTable, $foreignCol, $srcCol) | |
leftJoin ($foreignTable, $foreignCol, $srcCol) | |
Left Join. | |
rightJoin ($foreignTable, $foreignCol, $srcCol) | |
Right Join. | |
crossJoin ($foreignTableName) | |
Cross join. | |
byPassRelation () | |
passThroughRelation () | |
Private Member Functions | |
minExport ($fetchAll, $trgCol=false) |
use when overload support is not available to your PHP Installation If overload support isavailable use zOrm_magic instead. However in most of the cases overload is supported
Definition at line 36 of file nomagic.php.
zOrm_noMagic::identifyBy | ( | $ | colAliasName, | |
$ | val, | |||
$ | op = '=' , |
|||
$ | mandatory = true | |||
) |
Sets the Criteria for a Column. Which is latter merged to build the where query. e.g. You can use identifyBy('ColAliasName', 'Value', '=', true)
for a list of Operators you can use see zOrm_core::addAliasCriteria() if $mandatory flag is set to true and operator will be used to merge while building the where query else or operator will be used.
$colAliasName | string Column Alias Name | |
$val | string value of the Column in the Criteria | |
$op | string Operator that will be used between Column and Value | |
$mandatory | boolean if set to true and will be used else or will be used. |
Definition at line 49 of file nomagic.php.
References zOrm_core::$pk, $val, zOrm_core::addAliasCriteria(), zOrm_core::addColCriteria(), and perror().
Referenced by zOrm_magic::__call(), and findBy().
00049 { 00050 $cnj = ($mandatory) ? 'and' : 'or'; 00051 if(!eregi('pk', $colAliasName)){ 00052 if(!isset($this->lex['alias'][strtolower($colAliasName)])){ 00053 perror("<code>zigmoyd.orm.identifyBy$colAliasName</code><br />Invalid Column $colAliasName on table $this->tableAlias"); 00054 return false; 00055 } 00056 return $this->addAliasCriteria($this->lex['alias'][strtolower($colAliasName)], $val, $op, $cnj, true); 00057 }else{ 00058 if(!is_array($val)){ 00059 perror("<code>zigmoyd.orm.identifyBy$colAliasName</code><br />2nd Argument for Value must be an array ".gettype($val)." Given"); 00060 return false; 00061 } 00062 foreach($this->pk as $i => $pk){ 00063 if(!isset($val[$i])){ 00064 $useHint = ''; 00065 $pkTable = '<table border = "1" style="font: 12px Verdana, Arial, Helvetica, sans-serif;border-collapse: collapse;width: 200px;border: 2px solid #990000;"><tr style="border-top: 1px solid #990000;border-bottom: 1px solid #990000;background: #990000;color: #FFF3F3;"><td>Column Name</td><td>Value</td></tr>'; 00066 foreach($this->pk as $j => $pkt){ 00067 $pkTable .= "<tr style='border: 1px solid #990000;padding: 0 0.5em;color: #990000'><td>$pkt</td><td>".@$val[$j]."</td></tr>"; 00068 //(isset($args[$j])) ? $useHint .= " $args[$j]," : $useHint .= ' $value_for_'.$pkt.','; 00069 } 00070 $useHint = trim($useHint, ","); 00071 $pkTable .= "</table>"; 00072 perror('<code>zigmoyd.orm.identifyBy("pk", $value, '.$op.')</code><br />Your Table <code style="background-color: #FFFFFF;font-weight: normal;">'.$this->tableAlias.'</code> Uses Multiple Column Primary Key So the Combination of those fields must be unique.<br /> 00073 So you must provide multiple Values for Different Columns (primary Keys) serially<br /> 00074 But the Problem is No Value has been supplied for Column Alias <code style="background-color: #FFFFFF;font-weight: normal;">'.$this->lex['aliasProperCaps'][$pk].'</code> Real Column Name <code style="background-color: #FFFFFF;font-weight: normal;">'.$pk.'</code><br /> 00075 For a Better help Here is the list of Primary Keys and their values (as Supplied By You)<br />'.$pkTable.'<br />'); 00076 //you should use something like<br /><code style="background-color: #FFFFFF;font-weight: normal;">$this->db->'.$this->__struct->alias.'->'.$methodName."(".trim($useHint).")</code>; Instead"); 00077 return false; 00078 } 00079 $this->addColCriteria($pk, $val[$i], $op, $cnj, true); 00080 } 00081 } 00082 }
zOrm_noMagic::set | ( | $ | colAliasName, | |
$ | Value, | |||
$ | quote = true | |||
) |
set a value to a Column. If $quote Flag is set to true Value is Quoted using (') Single Quotes.
$colAliasName | string Column Alias name. | |
$value | strign Column Value. | |
$quote | boolean Quote Flag if set to true Value is Quoted using (') Single Quotes else not. |
Definition at line 91 of file nomagic.php.
References perror(), and zOrm_core::writeColAlias().
00091 { 00092 if(!isset($this->lex['alias'][strtolower($colAliasName)])){ 00093 perror("<code>zigmoyd.orm.set$colAliasName</code><br />Invalid Column $colAliasName on table $this->tableAlias"); 00094 return false; 00095 } 00096 return $this->writeColAlias($this->lex['alias'][strtolower($colAliasName)], $Value, $quote); 00097 }
zOrm_noMagic::fetch | ( | $ | colAliasName, | |
$ | flag = true | |||
) |
marks a Column to be fetched/selected.
$colAliasName | string Column Alias name. | |
$flag | boolean mark/UnMark Column to select. |
Definition at line 104 of file nomagic.php.
References perror(), and zOrm_core::readAlias().
Referenced by zOrm_magic::__call(), fetchAs(), find(), and findBy().
00104 { 00105 if(!eregi('all', $colAliasName)){ 00106 if(!isset($this->lex['alias'][strtolower($colAliasName)])){ 00107 perror("<code>zigmoyd.orm.fetch$colAliasName</code><br />Invalid Column $colAliasName on table $this->tableAlias"); 00108 return false; 00109 } 00110 return $this->readAlias($this->lex['alias'][strtolower($colAliasName)], $flag); 00111 }else{ 00112 foreach($this->lex['aliasProperCaps'] as $aliasName){ 00113 $this->readAlias($aliasName, $flag); 00114 } 00115 } 00116 return true; 00117 }
zOrm_noMagic::fetchAs | ( | $ | colAliasName, | |
$ | virtualAliasName | |||
) |
fetch a Column with a Different Temporary alias.
$colAliasName | string Column Alias name. | |
$virtualAliasName | strign the new Alias name to be used |
Definition at line 124 of file nomagic.php.
References fetch(), and perror().
Referenced by zOrm_magic::__call().
00124 { 00125 if(!isset($this->lex['alias'][strtolower($colAliasName)])){ 00126 perror("<code>zigmoyd.orm.fetch$colAliasName"."As".$virtualAliasName."</code><br />Invalid Column $colAliasName on table $this->tableAlias"); 00127 return false; 00128 } 00129 $realColName = $this->alias2real($this->lex['alias'][strtolower($colAliasName)]); 00130 $realAlias = $this->lex['aliasProperCaps'][$realColName]; 00131 $this->lex['aliasProperCaps'][$realColName] = $virtualAliasName; 00132 $retSet = $this->fetch($colAliasName); 00133 //$lex['aliasProperCaps'][$realColName] = $realAlias; 00134 return $retSet; 00135 }
zOrm_noMagic::find | ( | $ | colAliasName, | |
$ | indexKey = null | |||
) |
fetch -> select -> execute -> export -> returns value of a Column. may return a single scaler Value if a Column name has been supplied for find operation. if "all" has been supplied returns an object or array. you can also specify an Index key with which the array will be index if an array is returned.
$colAliasName | string Column Alias Name to find. | |
$indexKey | strign Optional Index Key |
Definition at line 147 of file nomagic.php.
References fetch(), zOrm_base::index(), and minExport().
Referenced by zOrm_magic::__call(), and findBy().
00147 { 00148 if(strlen($indexKey)){ 00149 $this->fetch($indexKey); 00150 $this->index($indexKey); 00151 } 00152 if($this->fetch($colAliasName)){ 00153 return $this->minExport(eregi('all', $colAliasName), $colAliasName); 00154 }else{ 00155 return false; 00156 } 00157 }
zOrm_noMagic::findBy | ( | $ | colAliasName, | |
$ | searchCol, | |||
$ | val, | |||
$ | op = null , |
|||
$ | indexCol = null | |||
) |
finds a Columns Value by another Column. fetch's a Column and sets a Where Criteria on another Criteria at the same time. if "all" has been supplied as the first Column Name returns an object or array. you can also specify an Index key with which the array will be index if an array is returned. you can also specify an Index key with which the array will be index if an array is returned.
$colAliasName | string Column Alias Name to find. | |
$searchCol | string Column agains which the criteria will be set. | |
$val | mixed Value of the Column for Criteria. | |
$op | strign Operator that will be used on Criteria | |
$indexKey | string Optional Index Key |
Definition at line 175 of file nomagic.php.
References $val, fetch(), find(), identifyBy(), zOrm_base::index(), and minExport().
00175 { 00176 if($op == null)$op = '='; 00177 if($this->isJoined){ 00178 $this->joiner->identifyBy($searchCol, $val, $op); 00179 }else{ 00180 $this->identifyBy($searchCol, $val, $op); 00181 } 00182 if(!strlen($indexCol)){ 00183 return $this->find($colAliasName); 00184 }else{ 00185 $this->fetch($indexCol); 00186 $this->index($indexCol); 00187 if($this->fetch($colAliasName)){ 00188 return $this->minExport(eregi('all', $colAliasName), $colAliasName); 00189 }else{ 00190 return false; 00191 } 00192 } 00193 }
zOrm_noMagic::minExport | ( | $ | fetchAll, | |
$ | trgCol = false | |||
) | [private] |
Minimal Export.
For internal use only.
$fetchAll | boolean if true fetch all. | |
$trgCol | boolean if true set a target column. |
Definition at line 202 of file nomagic.php.
References zOrm_base::export().
Referenced by find(), and findBy().
00202 { 00203 $resSet = $this->export(); 00204 if(!$resSet)return false; 00205 switch(count($resSet)){ 00206 case 0: 00207 return false; 00208 case 1: 00209 switch($fetchAll){ 00210 case true: 00211 foreach($resSet as $Row) 00212 return $Row; 00213 case false: 00214 foreach($resSet as $Row) 00215 return $Row->colList[$this->lex['alias'][strtolower($trgCol)]];//Case Insencitive 00216 //return $resSet[0]->colList[$trgCol];//Case Sensitive 00217 } 00218 default: 00219 switch($fetchAll){ 00220 case true: 00221 return $resSet; 00222 case false: 00223 $retSet = array(); 00224 foreach($resSet as $i => $resObj){ 00225 $retSet[$i] = $resSet[$i]->colList[$this->lex['alias'][strtolower($trgCol)]];//Case Insencitive 00226 //$retSet = $resSet[0]->colList[$trgCol];//Case Sensitive 00227 } 00228 return $retSet; 00229 } 00230 } 00231 }
zOrm_noMagic::isPk | ( | $ | colAliasName | ) |
Chaecks wheather or not the given Column is Primary key or not.
$colAliasName | strign Column Alias Name to check. |
Definition at line 238 of file nomagic.php.
References perror().
00238 { 00239 if(!isset($this->lex['alias'][strtolower($colAliasName)])){ 00240 perror("<code>zigmoyd.isPk()</code><br />non Existing Column $colAliasName"); 00241 return false; 00242 }else{ 00243 return in_array($this->alias2real($this->lex['alias'][strtolower($colAliasName)]), $this->pk); 00244 } 00245 }
zOrm_noMagic::join | ( | $ | cleanUp = true |
) |
Tries to autojoin. Joins automatically with the related tables with the relating column. Remember it tries to detect the foriegn keys to do this operation automatically. On some servers(sourceforge.net as on 2006) you dont have permissions to check this. so at that time auto join will not work so use forceJoin() at that time.
$cleanUp | boolean if set to true cleans up the lexims after operation finishes. |
Definition at line 254 of file nomagic.php.
References $__ZigOrm, and zLogger::debug().
00254 { 00255 zLogger::debug("Issuing AUTOJOIN to join foreign Tables if exists", 'orm.table'.$this->realTableName); 00256 global $__ZigOrm; 00257 if(is_array($this->fk)){ 00258 foreach($this->fk as $srcCol => $refObj){ 00259 if(!$this->lex['join']['type']){ 00260 $this->lex['join']['type'] = ZIGORM_Q_AUTOJOIN; 00261 } 00262 $this->lex['join']['on'][$refObj->table][$srcCol] = $refObj->col; 00263 } 00264 } 00265 }
zOrm_noMagic::forceJoin | ( | $ | foreignTableName, | |
$ | foreignCol, | |||
$ | srcCol | |||
) |
Force Join. Forcefully joins with a table provided using the provided Column.
$foreignTableName | string Foreign Table. | |
$foreignCol | string Foreign column. | |
$srcCol | strign column of this table joining in the ralationship. |
Definition at line 273 of file nomagic.php.
References $__ZigOrm, zOrm_core::colAliasExists(), dataDict, zLogger::debug(), and perror().
Referenced by innerJoin(), leftJoin(), and rightJoin().
00273 { 00274 zLogger::debug("Forcing Join $foreignTableName.$foreignCol With $this->realTableName.$srcCol ", 'orm.table'.$this->realTableName); 00275 $this->__rdbmsJoin = true; 00276 global $__ZigOrm; 00277 $tableAliasList = array_flip($__ZigOrm->dataDict->tables); 00278 if(isset($tableAliasList[$foreignTableName])){ 00279 if(!$this->colAliasExists($srcCol)){ 00280 perror("<code>zigmoyd.orm.get.join</code><br />Failed to join as real column name of Column Alias <code style=\"background-color: #FFFFFF;font-weight: normal;\">$srcCol</code> on table <code style=\"background-color: #FFFFFF;font-weight: normal;\">".$this->lex['table']."</code> could not be fetched"); 00281 return false; 00282 } 00283 $srcCol = $this->alias2real($srcCol); 00284 $this->fk[$srcCol] = new stdClass(); 00285 $this->fk[$srcCol]->table = $tableAliasList[$foreignTableName]; 00286 $this->fk[$srcCol]->col = $this->alias2real($foreignCol); 00287 if(class_exists($foreignTableName)){ 00288 $this->{$foreignTableName} = new $foreignTableName(); 00289 }else{ 00290 perror("<code>zigmoyd.orm.get.join</code><br />Class $foreignTableName not found"); 00291 return false; 00292 } 00293 }else{ 00294 perror("<code>zigmoyd.orm.get.join</code><br />Failed to join as real table name of Table Alias <code style=\"background-color: #FFFFFF;font-weight: normal;\">$foreignTableName</code> not found<br />Plese make sure that you are joining after Instantiating that Table's OrmClass"); 00295 return false; 00296 } 00297 return true; 00298 }
zOrm_noMagic::innerJoin | ( | $ | foreignTable, | |
$ | foreignCol, | |||
$ | srcCol | |||
) |
Performs InnerJoin. Performs InnerJoin with a table provided using the provided Column.
$foreignTableName | string Foreign Table. | |
$foreignCol | string Foreign column. | |
$srcCol | strign column of this table joining in the ralationship. |
Definition at line 306 of file nomagic.php.
References zLogger::debug(), and forceJoin().
00306 { 00307 zLogger::debug("Forcing Inner Join $foreignTable.$foreignCol With $this->realTableName.$srcCol ", 'orm.table'.$this->realTableName); 00308 $this->__rdbmsJoin = true; 00309 if($this->forceJoin($foreignTable, $foreignCol, $srcCol)){ 00310 $this->lex['join']['type'] = ZIGORM_JOIN_INNER; 00311 }else{ 00312 return false; 00313 } 00314 }
zOrm_noMagic::leftJoin | ( | $ | foreignTable, | |
$ | foreignCol, | |||
$ | srcCol | |||
) |
Left Join.
$foreignTableName | string Foreign Table. | |
$foreignCol | string Foreign column. | |
$srcCol | strign column of this table joining in the ralationship. |
Definition at line 323 of file nomagic.php.
References zLogger::debug(), and forceJoin().
00323 { 00324 zLogger::debug("Forcing Left Join $foreignTable.$foreignCol With $this->realTableName.$srcCol ", 'orm.table'.$this->realTableName); 00325 $this->__rdbmsJoin = true; 00326 if($this->forceJoin($foreignTable, $foreignCol, $srcCol)){ 00327 $this->lex['join']['type'] = ZIGORM_JOIN_LEFT; 00328 }else{ 00329 return false; 00330 } 00331 }
zOrm_noMagic::rightJoin | ( | $ | foreignTable, | |
$ | foreignCol, | |||
$ | srcCol | |||
) |
Right Join.
$foreignTableName | string Foreign Table. | |
$foreignCol | string Foreign column. | |
$srcCol | strign column of this table joining in the ralationship. |
Definition at line 340 of file nomagic.php.
References zLogger::debug(), and forceJoin().
00340 { 00341 zLogger::debug("Forcing Right Join $foreignTable.$foreignCol With $this->realTableName.$srcCol ", 'orm.table'.$this->realTableName); 00342 $this->__rdbmsJoin = true; 00343 if($this->forceJoin($foreignTable, $foreignCol, $srcCol)){ 00344 $this->lex['join']['type'] = ZIGORM_JOIN_RIGHT; 00345 }else{ 00346 return false; 00347 } 00348 }
zOrm_noMagic::crossJoin | ( | $ | foreignTableName | ) |
Cross join.
For internal use only.
Cross Join doesn't need any foreign or local Column name But zigmoyd needs so using a Dummy Column Name zig_orm_c_dummy_src_!<>#^&*()+=\. such taht it doesn't have any chance to conflict with the real column names in any situation
$foreignTableName | string |
Definition at line 356 of file nomagic.php.
References $__ZigOrm, zOrm_core::$tableAlias, dataDict, zLogger::debug(), and perror().
00356 { 00357 zLogger::debug("Issuing Cross Join $foreignTableName With $this->realTableName", 'orm.table'.$this->realTableName); 00358 $this->__rdbmsJoin = true; 00359 global $__ZigOrm; 00360 $tableAlias = array_flip($__ZigOrm->dataDict->tables); 00361 $this->lex['join']['on'][$tableAlias[$foreignTableName]] = true; 00362 if(class_exists($foreignTableName)){ 00363 $this->fk["zig_orm_c_dummy_src_!<>@#%^&*()+=\."]->table = $tableAlias[$foreignTableName]; 00364 $this->fk["zig_orm_c_dummy_src_!<>@#%^&*()+=\."]->col = "zig_orm_c_dummy_fk_!<>@#%^&*()+=\."; 00365 $this->{$foreignTableName} = new $foreignTableName(); 00366 $this->lex->join->type = ZIGORM_JOIN_CROSS; 00367 }else{ 00368 perror("<code>zigmoyd.orm.get.join</code><br />Class $foreignTableName not found"); 00369 return false; 00370 } 00371 }
zOrm_noMagic::byPassRelation | ( | ) |
zOrm_noMagic::passThroughRelation | ( | ) |