@@ 973-985 (lines=13) @@ | ||
970 | * @param array $query_params like EEM_Base's $query_params variable. |
|
971 | * @return EE_Base_Class | NULL |
|
972 | */ |
|
973 | function get_one($query_params = array()){ |
|
974 | if( ! is_array( $query_params ) ){ |
|
975 | EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
976 | $query_params = array(); |
|
977 | } |
|
978 | $query_params['limit'] = 1; |
|
979 | $items = $this->get_all($query_params); |
|
980 | if(empty($items)){ |
|
981 | return null; |
|
982 | }else{ |
|
983 | return array_shift($items); |
|
984 | } |
|
985 | } |
|
986 | ||
987 | ||
988 | ||
@@ 4312-4324 (lines=13) @@ | ||
4309 | * @param array $query_params |
|
4310 | * @return EE_Base_Class |
|
4311 | */ |
|
4312 | function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
4313 | if( ! is_array( $query_params ) ){ |
|
4314 | EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
4315 | $query_params = array(); |
|
4316 | } |
|
4317 | $query_params['limit'] = 1; |
|
4318 | $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
4319 | if(is_array($copies)){ |
|
4320 | return array_shift($copies); |
|
4321 | }else{ |
|
4322 | return null; |
|
4323 | } |
|
4324 | } |
|
4325 | ||
4326 | ||
4327 |