Changeset 973
- Timestamp:
- 07/25/08 18:19:04 (3 months ago)
- Files:
-
- branches/action_mailer/lib/Ak.php (modified) (1 diff)
- branches/action_mailer/lib/AkActiveRecord.php (modified) (5 diffs)
- branches/action_mailer/lib/AkActiveRecord/AkAssociatedActiveRecord.php (modified) (1 diff)
- branches/action_mailer/lib/AkPlugin/AkPluginManager.php (modified) (1 diff)
- branches/action_mailer/lib/utils/generators/scaffold/sintags_templates/controller.php (modified) (1 diff)
- branches/action_mailer/lib/utils/generators/scaffold/templates/controller.php (modified) (1 diff)
- branches/action_mailer/test/unit/lib/AkActiveRecord/AkValidation.php (modified) (2 diffs)
- branches/action_mailer/test/unit/lib/AkActiveRecord/_AkActiveRecord_find.php (copied) (copied from trunk/test/unit/lib/AkActiveRecord/_AkActiveRecord_find.php)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/action_mailer/lib/Ak.php
r972 r973 1127 1127 foreach ($array as $key => $value) { 1128 1128 $key = is_numeric($key) ? $parent : $key; 1129 $value = is_array($value) ? "\r\n". xmlFromArray($value, '', $key) : $value;1129 $value = is_array($value) ? "\r\n".Ak::array_to_xml($value, '', $key) : $value; 1130 1130 $_tags[$key] = $key; 1131 1131 $xml .= sprintf("<%s>%s</%s>\r\n", $key, $value, $key); branches/action_mailer/lib/AkActiveRecord.php
r821 r973 957 957 function &_findEvery($options) 958 958 { 959 $limit = isset($options['limit']) ? $options['limit'] : null;960 $offset = isset($options['offset']) ? $options['offset'] : null;961 962 $sql = $this->constructFinderSql($options);963 if(!empty($options['bind']) && is_array($options['bind']) && strstr($sql,'?')){964 $sql = array_merge(array($sql),$options['bind']);965 }966 967 959 if((!empty($options['include']) && $this->hasAssociations())){ 968 960 $result =& $this->findWithAssociations($options); 969 961 }else{ 962 $sql = $this->constructFinderSql($options); 963 if(!empty($options['bind']) && is_array($options['bind']) && strstr($sql,'?')){ 964 $sql = array_merge(array($sql),$options['bind']); 965 } 966 970 967 $result =& $this->findBySql($sql); 971 968 } … … 1031 1028 return false; 1032 1029 } 1033 $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', ' order', 'sort', 'bind', 'select','select_prefix', 'readonly');1030 $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', 'group', 'order', 'sort', 'bind', 'select','select_prefix', 'readonly'); 1034 1031 foreach (array_keys($options) as $key){ 1035 1032 if (!in_array($key,$valid_keys)){ … … 1095 1092 } 1096 1093 1097 }1098 1099 function _validateFindOptions(&$options)1100 {1101 $valid_keys = array('conditions', 'include', 'joins', 'limit', 'offset', 'order', 'bind', 'select','select_prefix', 'readonly');1102 foreach (array_keys($options) as $key){1103 if (!in_array($key,$valid_keys)) unset($options[$key]);1104 }1105 1094 } 1106 1095 … … 1357 1346 } 1358 1347 1359 $sql .= !empty($options['order']) ? ' ORDER BY '.$options['order'] : ''; 1348 $sql .= !empty($options['group']) ? ' GROUP BY '.$options['group'] : ''; 1349 $sql .= !empty($options['order']) ? ' ORDER BY '.$options['order'] : ''; 1360 1350 1361 1351 $this->_db->addLimitAndOffset($sql,$options); … … 3993 3983 $attribute_names = Ak::toArray($attribute_names); 3994 3984 foreach ($attribute_names as $attribute_name){ 3995 if( 3996 $allow_null ? 3997 ( 3998 isset($this->$attribute_name) ? 3999 ( 4000 $only_integer ? 4001 !is_integer(@$this->$attribute_name) : 4002 !is_numeric(@$this->$attribute_name) 4003 ) : 4004 false 4005 ) : 4006 ( 4007 isset($this->$attribute_name) ? 4008 ($only_integer ? !is_integer(@$this->$attribute_name) : !is_numeric(@$this->$attribute_name)) : 4009 true 4010 ) 4011 ) 4012 { 3985 if (isset($this->$attribute_name)){ 3986 $value = $this->$attribute_name; 3987 if ($only_integer){ 3988 $is_int = is_numeric($value) && (int)$value == $value; 3989 $has_error = !$is_int; 3990 }else{ 3991 $has_error = !is_numeric($value); 3992 } 3993 }else{ 3994 $has_error = $allow_null ? false : true; 3995 } 3996 3997 if ($has_error){ 4013 3998 $this->addError($attribute_name, $message); 4014 3999 } branches/action_mailer/lib/AkActiveRecord/AkAssociatedActiveRecord.php
r660 r973 343 343 return $objects; 344 344 } 345 $result =& $this->_generateObjectGraphFromResultSet($results,$included_associations,$virtual_limit); 346 return $result; 347 } 348 349 /** 350 * Pass hand-made sql directly to _db->execute and generate the OG with this method. 351 * 352 * @param ADOResultSet $results a result set from Db->execute 353 * @param array $included_associations just like in ->find(); $options['include']; but in fact unused 354 * @param mixed $virtual_limit int or false; unsure if this works 355 * @return array ObjectGraph as an array 356 */ 357 function &_generateObjectGraphFromResultSet($results,$included_associations = array(), $virtual_limit = false) 358 { 359 $objects = array(); 345 360 346 361 $i = 0; branches/action_mailer/lib/AkPlugin/AkPluginManager.php
r822 r973 215 215 function guessBestInstallMethod($options = array()) 216 216 { 217 if( is_dir($options['parameters'])){217 if(!empty($options['parameters']) && is_dir($options['parameters'])){ 218 218 return 'local directory'; 219 219 }elseif($this->canUseSvn()){ branches/action_mailer/lib/utils/generators/scaffold/sintags_templates/controller.php
r647 r973 11 11 function index() 12 12 { 13 $this-> performAction('listing');13 $this->redirectToAction('listing'); 14 14 } 15 15 branches/action_mailer/lib/utils/generators/scaffold/templates/controller.php
r647 r973 11 11 function index() 12 12 { 13 $this-> performAction('listing');13 $this->redirectToAction('listing'); 14 14 } 15 15 branches/action_mailer/test/unit/lib/AkActiveRecord/AkValidation.php
r468 r973 671 671 $Person->validatesNumericalityOf('age'); 672 672 $this->assertFalse($Person->hasErrors()); 673 674 $Person->clearErrors(); 675 $Person->age = '18'; 676 $Person->validatesNumericalityOf('age','not_valid',true); 677 $this->assertFalse($Person->hasErrors()); 673 678 674 679 $Person->clearErrors(); … … 677 682 $this->assertFalse($Person->hasErrors()); 678 683 684 $Person->clearErrors(); 685 $Person->age = null; 686 $Person->validatesNumericalityOf('age', 'not_valid',false, false); 687 $this->assertTrue($Person->hasErrors()); 679 688 } 680 689
