00001 <?php
00029 class zigRowSet extends zCore{
00037 var $colList;
00045 var $handle;
00046 var $conflictable;
00047
00048
00057 function save(&$handle){
00058
00059 $src = $this->colList;
00060 foreach($src as $col => $val){
00061 $handle->writeColAlias($col, $val, ZIGORM_QUOTE, true);
00062 }
00063 foreach($handle->pk as $pk){
00064 $handle->identifyBy($handle->lex['aliasProperCaps'][$pk], $this->colList[$handle->lex['aliasProperCaps'][$pk]]);
00065 }
00066 return $handle->update();
00067 }
00076 function remove(&$handle){
00077 foreach($handle->pk as $pk){
00078 $handle->identifyBy($handle->lex['aliasProperCaps'][$pk], $this->colList[$handle->lex['aliasProperCaps'][$pk]]);
00079 }
00080 return $handle->remove();
00081 }
00088 function delete(&$handle){
00089 return $this->remove(&$handle);
00090 }
00099 function __set($colAlias, $colValue){
00100 if(!isset($this->colList[$colAlias])){
00101
00102 foreach($this->colList as $ca => $cv){
00103 if(strtolower($ca) === strtolower($colAlias)){
00104 $this->colList[$ca] = $colValue;
00105 return true;
00106 }
00107 }
00108
00109 perror('<code>zigmoyd.orm.rowSet.set'.$colAlias.'</code><br />column '.$colAlias.' doesn\'t exist');
00110 return false;
00111 }else{
00112 $this->colList[$colAlias] = $colValue;
00113 return true;
00114 }
00115 }
00124 function __get($colAlias, &$value){
00125 if($colAlias == 'colList')return $this->colList;
00126 if(!isset($this->colList[$colAlias])){
00127
00128 foreach($this->colList as $ca => $cv){
00129 if(strtolower($ca) === strtolower($colAlias)){
00130 $value = $this->colList[$ca];
00131 return true;
00132 }
00133 }
00134
00135 perror('<code>zigmoyd.orm.'.$this->handle->caller->__struct->alias.'.rowSet.get'.$colAlias.'</code><br />column '.$colAlias.' doesn\'t exist');
00136 return true;
00137 }else{
00138 $value = $this->colList[$colAlias];
00139 return true;
00140 }
00141 }
00153 function __call($methodName, $args, &$return){
00154 switch(true){
00155 case (preg_match('~set(\w+)~i', $methodName, $m) >= 1):
00156 if(!isset($args[0])){
00157 perror('<code>zigmoyd.orm.'.$methodName.'($value)</code><br />you must supply 1 Argument No argument has been Suplied');
00158 exit;
00159 }
00160 if(eregi('all', $m[1])){
00161 foreach($args[0] as $key => $val){
00162 if(isset($this->colList[$key])){
00163 $this->__set($m[1], $val);
00164 }else{
00165 perror('<code>zigmoyd.orm.setAll()</code><br />Column <code style="background-color: #FFFFFF;font-weight: normal;">'.$key.'</code> doesn\'t exist');
00166 }
00167 }
00168 }else{
00169 $ret = $this->__set($m[1], $args[0]);
00170 }
00171 break;
00172 case (preg_match('~get(\w+)~i', $methodName, $m) >= 1):
00173 if(isset($args[0])){
00174 perror('<code>zigmoyd.orm.'.$methodName.'($value)</code><br />you must supply 1 Argument No argument has been Suplied');
00175 return false;
00176 }
00177 if(eregi('all', $m[1]))$ret = $this->colList;
00178 else $this->__get($m[1], $ret);
00179 break;
00180 default:
00181 perror('<code>zigmoyd.orm.'.$methodName.'($value)</code><br />Method doesn\'t exists Plese Check the manual');
00182 return false;
00183 }
00184 $return = $ret;
00185 return true;
00186 }
00193 function conflicts($colAlias){
00194 $this->conflictable = $colAlias;
00195
00196 $colList = $this->colList;
00197 foreach($colList as $ca => $cv){
00198 if(strtolower($ca) === strtolower($this->conflictable)){
00199 return true;
00200 }
00201 }
00202
00203 return false;
00204 }
00210 function autoResolve(){
00211
00212 $colList = $this->colList;
00213 foreach($colList as $ca => $cv){
00214 if(strtolower($ca) === strtolower($this->conflictable)){
00215
00216 $this->conflictable = null;
00217 return $this->colList[$ca];
00218 }
00219 }
00220
00221 $this->conflictable = null;
00222 perror('<code>zigmoyd.orm.'.$this->handle->caller->__struct->alias.'.rowSet.get'.$this->conflictable.'</code><br />Wired Problem Conflict occured But could not be resolved for column '.$this->conflictable);
00223 return false;
00224 }
00225 }
00227 ?>