Public Member Functions | |
fetchCol () | |
fetchColAsAlias () | |
setCol ($value) | |
identifyByCol ($value) | |
identifyByColOp ($value) | |
findCol1ByCol2 ($value, $indxCol=null, $ordCol=null, $ordMode=ZIGORM_ORDER_ASC) | |
findCol1ByCol2Op ($value, $indxCol=null, $ordCol=null, $ordMode=ZIGORM_ORDER_ASC) | |
findCol ($indxCol=null, $ordCol=null, $ordMode=ZIGORM_ORDER_ASC) | |
Private Member Functions | |
lexize ($clause, $args) | |
__call ($methodName, $args, &$return) |
Definition at line 31 of file magic.php.
zOrm_magic::lexize | ( | $ | clause, | |
$ | args | |||
) | [private] |
For internal use only.
Definition at line 36 of file magic.php.
References zOrm_core::$lex.
Referenced by __call().
00036 { 00037 //{ Analyze the Column Name and Opcode and may 00038 $opcode = array( 00039 'equals', 00040 'greaterthan', 00041 'greaterthanequals', 00042 'lessthan', 00043 'lessthanquals', 00044 'like', 00045 'notequals' 00046 ); 00047 foreach($opcode as $op)array_push($opcode, 'may'.$op); 00048 $opcode = array_reverse($opcode); 00049 for($i=0;$i<count($opcode);$i++)$opcode[$i] = strrev($opcode[$i]); 00050 $var = preg_match('~('.implode('|', $opcode).')?(\w+)~i', strrev($clause), $m); 00051 //{{ Assign Actual Symbol for the Textual Classes 00052 $opcode = array( 00053 'equals' => '=', 00054 'notequals' => '!=', 00055 'greaterthan' => '>', 00056 'greaterthanequals' => '>=', 00057 'lessthan' => '<', 00058 'lessthanequals' => '<=', 00059 'like' => 'LIKE' 00060 ); 00061 foreach($opcode as $op => $smb)$opcode['may'.$op] = $smb; 00062 //}} 00063 for($i=0;$i<count($m);$i++)$m[$i] = strrev($m[$i]); 00064 if(!strlen($m[1]))$m[1] = 'equals';//If no Symbol is given Make it Equals 00065 $lex = new stdClass(); 00066 (eregi('may', $m[1])) ? $lex->may=false : $lex->may=true; 00067 $lex->op = $opcode[$m[1]]; 00068 $lex->col = $m[2]; 00069 $lex->val = $args[0]; 00070 //} 00071 return $lex; 00072 }
zOrm_magic::__call | ( | $ | methodName, | |
$ | args, | |||
&$ | return | |||
) | [private] |
For internal use only.
Definition at line 77 of file magic.php.
References zOrm_core::$lex, $val, zOrm_noMagic::fetch(), zOrm_noMagic::fetchAs(), zOrm_noMagic::find(), zOrm_noMagic::identifyBy(), lexize(), zOrm_base::order(), and perror().
00077 { 00078 switch(true){ 00079 case (preg_match('~identifyBy(\w+)~i', $methodName, $m) >= 1): 00080 if(!isset($args[0])){ 00081 perror('<code>zigmoyd.orm.'.$methodName.'($value)</code><br />you must supply at least 1 Argument No argument has been Suplied'); 00082 $return = false; 00083 return true; 00084 } 00085 if(eregi('pk', $m[1])){ 00086 $val = array(); 00087 $listArgs = func_get_args(); 00088 $listArgs = $listArgs[1]; 00089 foreach($listArgs as $value){ 00090 if(!is_array($value)){ 00091 $val[] = $value; 00092 }else{ 00093 foreach($value as $innerVal){ 00094 $val[] = $innerVal; 00095 } 00096 } 00097 } 00098 }else{ 00099 $val = $args[0]; 00100 } 00101 $lex = $this->lexize(strtolower($m[1]), $args); 00102 $return = $this->identifyBy($lex->col, $val, $lex->op, $lex->may); 00103 return true; 00104 break; 00105 case (preg_match('~set(\w+)~i', $methodName, $m) >= 1): 00106 if(!isset($args[0])){ 00107 perror('<code>zigmoyd.orm.'.$methodName.'($value)</code><br />you must supply 1 Argument No argument has been Suplied'); 00108 $return = false; 00109 return true; 00110 } 00111 $return = $this->set($m[1], $args[0]); 00112 return true; 00113 break; 00114 case (preg_match('~fetch(\w+)As(\w+)~i', $methodName, $m) >= 1): 00115 if(isset($this->lex['alias'][strtolower("$m[1]As$m[2]")])){//If a Column exists with this name 00116 if(!isset($args[0]))$args[0] = true; 00117 $return = $this->fetch(strtolower("$m[1]As$m[2]"), $args[0]); 00118 return true; 00119 } 00120 if(eregi('all', $m[1])){ 00121 perror("use fetchAll() Instead, cause fetchAllAsSomeThing() doesn't have a meaning"); 00122 $return = false; 00123 return true; 00124 } 00125 $return = $this->fetchAs($m[1], $m[2]); 00126 return true; 00127 break; 00128 case (preg_match('~fetch(\w+)~i', $methodName, $m) >= 1): 00129 if(!isset($args[0]))$args[0] = true; 00130 $return = $this->fetch($m[1], $args[0]); 00131 return true; 00132 break; 00133 case (preg_match('~find(\w+)~i', $methodName, $m) >= 1): 00134 if(isset($args[1]) && strlen($args[1])){//The Order Column Is Given 00135 $ordWay = isset($args[2]) ? $args[2] : ZIGORM_ORDER_ASC; 00136 $this->order($args[1], $ordWay); 00137 } 00138 if(isset($args[0]) && strlen($args[0])){//The Index Column is Given 00139 $return = $this->find($m[1], $args[0]); 00140 }else{ 00141 $return = $this->find($m[1]); 00142 } 00143 return true; 00144 break; 00145 case (preg_match('~get(\w+)As(\w+)~i', $methodName, $m) >= 1): 00146 perror('<code>zigmoyd.orm.'.$this->__struct->alias.'.'.$methodName.'()</code><br />Method doesn\'t exists Plese Check the Documentation Properly<br />However I think You meant find or fetch instead of get'); 00147 return false; 00148 break; 00149 default: 00150 perror('<code>zigmoyd.orm.'.$this->__struct->alias.'.'.$methodName.'()</code><br />Method doesn\'t exists Plese Check the Documentation Properly'); 00151 exit; 00152 } 00153 }
zOrm_magic::fetchCol | ( | ) |
Fetch a Column more customized SELECT Operation. Find methods are Simple to use.But you can use only one Where clause at a time.But What if you need to use two where Clause at a time for that situation there is fetch a more customized approach. find methods just set one Column to be selected. If you want to select two columns use fetchCol1() and fetchCol2() so that both Col1 and Col2 will be flagged as to be selected.
fetchName()
Definition at line 164 of file magic.php.
zOrm_magic::fetchColAsAlias | ( | ) |
Fetch a Column with a Different Temporary Alias name. Works just like fetchCol() However On the returned RowSet (after invoking zOrm_base::export()) the provided alias Name will be used. Instead of Alias name set in ORM Map. This meant to be used to handle rare Column Alias Name Conflicts.
Definition at line 171 of file magic.php.
zOrm_magic::setCol | ( | $ | value | ) |
Set a Value on a Column. you can set value to a Column just like setName("Foo")
Which will be updated or inserted or deleted after invoking update() or insert() or delete() operation.
$value | string value to be set on that column. |
setName()
. Definition at line 183 of file magic.php.
zOrm_magic::identifyByCol | ( | $ | value | ) |
Set Criteria for a Column works like identifyById(1)
. sets a Criteria for the Col with = (equal) operator. e.g. identifyById(1)
set's an where clause id equals 1
$value | string Value of the Column in the Criteria |
identifyByPk(1)
identifyById(1)
Definition at line 196 of file magic.php.
zOrm_magic::identifyByColOp | ( | $ | value | ) |
Find one or all Column(s) By another Column or Primary Key with a Custom Single Criteria like findNameByIdEquals(1)
. fetch's value of one Column while adds a Criteria to another column and executes select Query and returns. value of the fetched Column.e.g. If you use findNameByIdGreaterThan(1)
it will return a string data representing the name who's id is greater than one else returns false. see identifyByColOp() for a set of Operators.
findNameByPkEquals(1)
.
You can use 'all' at the place of 'Col1' to fetch All Columns e.g. Full Row. which will return an object/array you can use it like findAllByIdEquals(1)
.
findNameByIdEquals(1)
findAllBySomethingEquals(1)
has been executed. If number of rows in the SELECT output is more than one it returns an array of rowSet Object. But if only one row has been returned it returns a RowSet Object. In the Same Way when you code findColumnBySomethingEquals(1)
it may return a string containing the value of that Column. or an array of strings. If your Code is written in such way that it expects iterable output from this method you should use zCDE Module and zCDE::toIterable() on its output. If your Criteria and fetch has generated multi Row result it will return an aray of strings. else it will return a string. However PHP doesn't have Strict type safty so that string will implecitely get converted to any premitive datatype in internal coertion. $value | string Value of the column against which criteria has to be set. |
Definition at line 224 of file magic.php.
zOrm_magic::findCol1ByCol2 | ( | $ | value, | |
$ | indxCol = null , |
|||
$ | ordCol = null , |
|||
$ | ordMode = ZIGORM_ORDER_ASC | |||
) |
Find one or all Column(s) By another Column or Primary Key like findNameById(1)
. fetch's value of one Column while adds an Equals Criteria to another column and executes select Quiry and returns. value of the fetched Column.e.g. If you use findNameById(1)
it will return a string data representing the name who's id is one else returns false.
findNameByPk(1)
.
You can use 'all' at the place of 'Col1' to fetch All Columns e.g. Full Row. which will return an object/array you can use it like findAllById(1)
.
findNameById(1)
findAllBySomething()
has been executed. If number of rows in the SELECT output is more than one it returns an array of rowSet Object. But if only one row has been returned it returns a RowSet Object. In the Same Way when you code findColumnBySomething()
it may return a string containing the value of that Column. or an array of strings. If your Code is written in such way that it expects iterable output from this method you should use zCDE Module and zCDE::toIterable() on its output. If your Criteria and fetch has generated multi Row result it will return an aray of strings. else it will return a string. However PHP doesn't have Strict type safty so that string will implecitely get converted to any premitive datatype in internal coertion.
You can optionally supply an additional argument for ordering. e.g. an order Column cn be given. You can specify order Types as ZIGORM_ORDER_ASC
and ZIGORM_ORDER_DESC
$value | string Value of the column against which criteria has to be set. | |
$indxCol | string Optional the Index Column with which to index the array defaults to null. | |
$ordCol | string Optional order Column whith which to order defaults to null | |
$ordMode | int Optional order Mode Ascending(ZIGORM_ORDER_ASC ) or descending(ZIGORM_ORDER_DESC ) defaults to ZIGORM_ORDER_ASC |
Definition at line 255 of file magic.php.
zOrm_magic::findCol1ByCol2Op | ( | $ | value, | |
$ | indxCol = null , |
|||
$ | ordCol = null , |
|||
$ | ordMode = ZIGORM_ORDER_ASC | |||
) |
Find one or all Column(s) By another Column or Primary Key with a Custom Single Criteria like findNameByIdEquals(1)
. fetch's value of one Column while adds a Criteria to another column and executes select Query and returns. value of the fetched Column.e.g. If you use findNameByIdGreaterThan(1)
it will return a string data representing the name who's id is greater than one else returns false. see identifyByColOp() for a set of Operators.
findNameByPkEquals(1)
.
You can use 'all' at the place of 'Col1' to fetch All Columns e.g. Full Row. which will return an object/array you can use it like findAllByIdEquals(1)
.
findNameByIdEquals(1)
findAllBySomethingEquals(1)
has been executed. If number of rows in the SELECT output is more than one it returns an array of rowSet Object. But if only one row has been returned it returns a RowSet Object. In the Same Way when you code findColumnBySomethingEquals(1)
it may return a string containing the value of that Column. or an array of strings. If your Code is written in such way that it expects iterable output from this method you should use zCDE Module and zCDE::toIterable() on its output. If your Criteria and fetch has generated multi Row result it will return an aray of strings. else it will return a string. However PHP doesn't have Strict type safty so that string will implecitely get converted to any premitive datatype in internal coertion.
You can optionally supply an additional argument for ordering. e.g. an order Column cn be given. You can specify order Types as ZIGORM_ORDER_ASC
and ZIGORM_ORDER_DESC
$value | string Value of the column against which criteria has to be set. | |
$indxCol | string Optional the Index Column with which to index the array defaults to null. | |
$ordCol | string Optional order Column whith which to order defaults to null | |
$ordMode | int Optional order Mode Ascending(ZIGORM_ORDER_ASC ) or descending(ZIGORM_ORDER_DESC ) defaults to ZIGORM_ORDER_ASC |
Definition at line 288 of file magic.php.
zOrm_magic::findCol | ( | $ | indxCol = null , |
|
$ | ordCol = null , |
|||
$ | ordMode = ZIGORM_ORDER_ASC | |||
) |
Find all Values of a Column as an array. you can execute findName() to get all Names. However you can also use findAll() which returns an array of RowSet Objects.
findAll()
. findName()
You can optionally supply an additional argument for indexing the resultant array. if an additional Index Column is supplied the result array will be indexed with values coming from the index Column
You can optionally supply an additional argument for ordering. e.g. an order Column cn be given. You can specify order Types as ZIGORM_ORDER_ASC
and ZIGORM_ORDER_DESC
$indxCol | string Optional the Index Column with which to index the array defaults to null. | |
$ordCol | string Optional order Column whith which to order defaults to null | |
$ordMode | int Optional order Mode Ascending(ZIGORM_ORDER_ASC ) or descending(ZIGORM_ORDER_DESC ) defaults to ZIGORM_ORDER_ASC |
Definition at line 305 of file magic.php.