Changeset 1365
- Timestamp:
- 08/07/09 05:15:55 (1 year ago)
- Files:
-
- trunk/lib/AkActiveRecord.php (modified) (5 diffs)
- trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/AkActiveRecord.php
r1361 r1365 842 842 $sql = 'DELETE FROM '.$this->getTableName().' WHERE '.$this->getPrimaryKey().' = '.$this->castAttributeForDatabase($this->getPrimaryKey(), $this->getId()); 843 843 if ($this->_db->delete($sql,$this->getModelName().' Destroy') !== 1){ 844 return $this->transactionFail();844 return $this->transactionFail(); 845 845 } 846 846 … … 1090 1090 1091 1091 } 1092 1093 1092 function quotedId($id = false) 1094 1093 { 1095 1094 return $this->castAttributeForDatabase($this->getPrimaryKey(), $id ? $id : $this->getId()); 1096 1095 } 1097 1098 1096 function _extractOptionsFromArgs(&$args) 1099 1097 { … … 1230 1228 $objects[] =& $this->instantiate($this->getOnlyAvailableAttributes($record), false); 1231 1229 } else if ($returns == 'simulated') { 1232 $objects[] = $this-> getOnlyAvailableAttributes($record);1230 $objects[] = $this->_castAttributesFromDatabase($this->getOnlyAvailableAttributes($record),$this); 1233 1231 } else if ($returns == 'array') { 1234 1232 1235 $objects[] = $this-> getOnlyAvailableAttributes($record);1233 $objects[] = $this->_castAttributesFromDatabase($this->getOnlyAvailableAttributes($record),$this); 1236 1234 } 1237 1235 } … … 3033 3031 */ 3034 3032 3035 function t($string, $array = null )3036 { 3037 return Ak::t($string, $array, AkInflector::underscore($this->getModelName()));3033 function t($string, $array = null,$model=null) 3034 { 3035 return Ak::t($string, $array, empty($model)?AkInflector::underscore($this->getModelName()):$model); 3038 3036 } 3039 3037 … … 3411 3409 if(empty($imported_cache[$column_name])){ 3412 3410 $class_name = isset($this->serialize[$column_name]) ? 3413 (is_string($this->serialize[$column_name]) ? $this->serialize[$column_name] : $column_name) : $column_name; 3414 Ak::import($class_name); 3411 (is_string($this->serialize[$column_name]) ? $this->serialize[$column_name] : $column_name) : false; 3412 if($class_name) { 3413 Ak::import($class_name); 3414 } 3415 3415 $imported_cache[$column_name] = true; 3416 3416 } trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php
r1351 r1365 258 258 $load_acts = isset($options['load_acts'])?$options['load_acts']:true; 259 259 260 $config = array('__owner'=>array('class'=>$this->getType(),'pk'=>$this->getPrimaryKey() ));260 $config = array('__owner'=>array('class'=>$this->getType(),'pk'=>$this->getPrimaryKey(),'instance'=>$this)); 261 261 262 262 $returns = isset($options['returns'])?$options['returns']:'default'; … … 313 313 } 314 314 } 315 $config['__owner'][$handler_name] = array('class'=>$class,'association_id'=>$association_id,'pk'=>$pk_name );315 $config['__owner'][$handler_name] = array('class'=>$class,'association_id'=>$association_id,'pk'=>$pk_name,'instance'=>$instance); 316 316 317 317 if(isset($association_options['conditions']) && is_array($association_options['conditions'])) { … … 493 493 $table_name = $instance->getTableName(); 494 494 } 495 $config[$handler_name][$sub_handler_name] = array('association_id'=>$sub_association_id,'class'=>$class_name,'pk'=>$pk );495 $config[$handler_name][$sub_handler_name] = array('association_id'=>$sub_association_id,'class'=>$class_name,'pk'=>$pk, 'instance'=>$instance); 496 496 $sub_associated_options = $sub_association_object->$sub_handler_name->getAssociatedFinderSqlOptionsForInclusionChain($prefix.'['.$handler_name.']'.($parent_is_plural?'[@'.$pk.']':''),'__owner__'.$parent_association_id, 497 497 $sub_options, $pluralize); … … 769 769 $association = $key; 770 770 771 if (isset($config[$key]) && $returns == 'array') {771 if (isset($config[$key])) { 772 772 $config = $config[$key]; 773 $association = $config['association_id']; 773 if($returns=='array') { 774 $association = $config['association_id']; 775 } 774 776 //$this->log('using association:'.$association); 775 777 } … … 780 782 781 783 } 784 $value=$this->_castAttributeFromDatabase($association,$value,$config['instance']); 782 785 $last = $value; 783 786 } … … 880 883 } 881 884 }*/ 882 $available = $this->_castAttributesFromDatabase($available,$instance);885 //$available = $this->_castAttributesFromDatabase($available,$instance); 883 886 $obj=&$parent->$assoc_name->build($available,false); 884 887
