Changeset 1287
- Timestamp:
- 04/26/09 11:32:27 (1 year ago)
- Files:
-
- trunk/lib/AkActiveRecord.php (modified) (6 diffs)
- trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php (modified) (2 diffs)
- trunk/lib/AkActiveRecord/AkAssociations/AkHasAndBelongsToMany.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/AkActiveRecord.php
r1286 r1287 1 1 <?php 2 Ak::compat('stripos'); 2 3 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 4 … … 965 965 }else{ 966 966 $sql = $this->constructFinderSql($options); 967 if (isset($options['wrap'])) { 968 $sql = str_replace('{query}',$sql,$options['wrap']); 969 } 967 970 if(!empty($options['bind']) && is_array($options['bind']) && strstr($sql,'?')){ 968 971 $sql = array_merge(array($sql),$options['bind']); … … 1002 1005 $options['conditions'] = $table_name.'.'.$this->getPrimaryKey().' = '.$ids[0].(empty($conditions)?'':' AND '.$conditions); 1003 1006 } else { 1007 Ak::compat('stripos'); 1004 1008 if (false!==($pos=stripos($conditions,' WHERE '))) { 1005 1009 $before_where = substr($conditions,0, $pos); … … 1024 1028 $options['conditions'] = $ids_condition.(empty($conditions)?'':' AND '.$conditions); 1025 1029 } else { 1030 Ak::compat('stripos'); 1026 1031 if (false!==($pos=stripos($conditions,' WHERE '))) { 1027 1032 $before_where = substr($conditions,0, $pos); … … 1054 1059 return false; 1055 1060 } 1056 $valid_keys = array(' conditions', 'include', 'joins', 'limit', 'offset', 'group', 'order', 'sort', 'bind', 'select','select_prefix', 'readonly');1061 $valid_keys = array('wrap','conditions', 'include', 'joins', 'limit', 'offset', 'group', 'order', 'sort', 'bind', 'select','select_prefix', 'readonly'); 1057 1062 foreach (array_keys($options) as $key){ 1058 1063 if (!in_array($key,$valid_keys)){ … … 1411 1416 } 1412 1417 } else { 1418 Ak::compat('stripos'); 1413 1419 if (($wherePos=stripos($sql,'WHERE'))!==false) { 1414 1420 if (!empty($type_condition)) { trunk/lib/AkActiveRecord/AkAssociatedActiveRecord.php
r1286 r1287 239 239 $result = false; 240 240 $options ['include'] = Ak::toArray($options ['include']); 241 241 242 242 $included_associations = array (); 243 243 $included_association_options = array (); … … 343 343 344 344 $sql = preg_replace('/,\s*,/',' , ',$sql); 345 345 346 if (isset($options['wrap'])) { 347 $sql = str_replace('{query}',$sql,$options['wrap']); 348 } 349 346 350 if (! empty($options ['bind']) && is_array($options ['bind']) && strstr($sql, '?')) { 347 351 $sql = array_merge(array ($sql ), $options ['bind']); trunk/lib/AkActiveRecord/AkAssociations/AkHasAndBelongsToMany.php
r1286 r1287 782 782 } 783 783 784 785 $join_class = $association_options['join_class_name']; 786 Ak::import($join_class); 787 $join_obj = new $join_class; 788 $join_class_columns = array_keys($join_obj->getColumns()); 789 foreach ($join_class_columns as $column_name){ 790 $finder_options['selection'] .= $parent_handler_name.'__'.$handler_name.'__'.$join_class.'.'.$column_name.' AS '.$selection_parenthesis.$prefix.'['.$handler_name.']'.($pluralize?'[@'.$pk.']':'').'['.$join_class.']['.$column_name.']'.$selection_parenthesis.', '; 791 } 792 784 793 $finder_options['selection'] = trim($finder_options['selection'], ', '); 785 794
