44 if( $DefaultValue ===
'_throw_exception' )
46 throw(
new Exception(
"Key '$Field' does not exists" ) );
50 return( $DefaultValue );
84 function get_field( &$Entity , $Field , $DefaultValue =
'_throw_exception' )
88 if( is_object( $Entity ) )
90 if( property_exists( $Entity , $Field ) )
92 return( $Entity->$Field );
98 if( is_array( $Entity ) )
100 if( array_key_exists( $Field , $Entity ) )
102 return( $Entity[ $Field ] );
108 throw(
new Exception(
"Illegal value was passed" ) );
110 catch( Exception $e )
146 function get_fields( &$Entity , $Fields , $DefaultValue =
'_throw_exception' )
151 $Fields = explode(
',' , $Fields );
153 foreach( $Fields as $i => $Field )
155 $Values [] =
get_field( $Entity , $Field , $DefaultValue );
160 catch( Exception $e )
196 if( is_object( $Entity ) )
198 if( property_exists( $Entity , $Field ) )
204 if( is_array( $Entity ) )
206 if( isset( $Entity[ $Field ] ) )
214 catch( Exception $e )
250 function get_field_ex( &$ArrayOfEntities , $Field , $DefaultValue =
'_throw_exception' )
254 $RetValues = array();
256 foreach( $ArrayOfEntities as $k => $v )
258 $RetValues [] =
get_field( $v , $Field , $DefaultValue );
261 return( $RetValues );
263 catch( Exception $e )
299 $FilterFunction = create_function(
'$Element' ,
"return( $Condition );" );
301 $FilteredArrayOfEntities = array_filter( $ArrayOfEntities , $FilterFunction );
303 return( $FilteredArrayOfEntities );
305 catch( Exception $e )
346 $DefaultValue =
'_throw_exception' )
350 $RetValues = array();
352 $FilteredArrayOfEntities =
array_filter_ex( $ArrayOfEntities , $Condition );
354 foreach( $FilteredArrayOfEntities as $k => $v )
356 $RetValues [] =
get_field( $v , $Field , $DefaultValue );
359 return( $RetValues );
361 catch( Exception $e )
401 if( count( $Array ) )
403 $Keys = array_keys( $Array );
405 if( is_array( $Array[ $Keys[ 0 ] ] ) )
408 foreach( $Array as $i => $Element )
416 if( $Field !==
false )
421 return( array_sum( $Array ) );
423 catch( Exception $e )
463 if( is_object( $Entity ) )
465 $Entity->$Field = $Value;
469 if( is_array( $Entity ) )
471 $Entity[ $Field ] = $Value;
477 catch( Exception $e )
522 if( is_object( $Entity ) )
524 array_push( $Entity->$Field , $Value );
527 if( is_array( $Entity ) )
529 array_push( $Entity[ $Field ] , $Value );
534 catch( Exception $e )
574 return( implode( $Str ,
get_field_ex( $Arr , $Field ) ) );
576 catch( Exception $e )
608 function extend( &$Destination , $Source )
612 if( $Source ===
false )
614 return( $Destination );
617 foreach( $Source as $k => $v )
619 $Destination =
set_field( $Destination , $k , $v );
622 return( $Destination );
624 catch( Exception $e )
660 if( $Field !==
false )
669 return( array_sum( $Array2 ) );
671 catch( Exception $e )
703 if( is_array( $Entity ) )
707 elseif( is_object( $Entity ) )
709 return(
new stdClass() );
713 throw(
new Exception(
"Illegal data type : ".gettype( $Entity ) ) );
716 catch( Exception $e )
752 if( is_array( $Fields ) ===
false )
754 $Fields = array( $Fields );
759 foreach( $Entity as $Field => $Value )
761 if( array_search( $Field , $Fields ) ===
false )
763 set_field( $ChangedEntity , $Field , $Value );
767 return( $Entity = $ChangedEntity );
769 catch( Exception $e )
801 if( is_array( $Scalar ) || is_object( $Scalar ) )
807 return( array( $Scalar ) );
810 catch( Exception $e )
848 foreach( $Array as $k => $v )
850 $Return[
get_field( $v , $Field ) ] = $v;
855 catch( Exception $e )
893 foreach( $Array as $k => $v )
897 if( isset( $Return[ $Key ] ) ===
false )
899 $Return[ $Key ] = array();
902 $Return[ $Key ][] = $v;
907 catch( Exception $e )
951 foreach( $Array as $i => $Element )
953 if(
get_field( $Element , $Field , $DefaultValue ) == $Value )
961 catch( Exception $e )