@@ 978-990 (lines=13) @@ | ||
975 | * @param array $query_params like EEM_Base's $query_params variable. |
|
976 | * @return EE_Base_Class | NULL |
|
977 | */ |
|
978 | function get_one($query_params = array()){ |
|
979 | if( ! is_array( $query_params ) ){ |
|
980 | 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' ); |
|
981 | $query_params = array(); |
|
982 | } |
|
983 | $query_params['limit'] = 1; |
|
984 | $items = $this->get_all($query_params); |
|
985 | if(empty($items)){ |
|
986 | return null; |
|
987 | }else{ |
|
988 | return array_shift($items); |
|
989 | } |
|
990 | } |
|
991 | ||
992 | ||
993 | ||
@@ 4321-4333 (lines=13) @@ | ||
4318 | * @param array $query_params |
|
4319 | * @return EE_Base_Class |
|
4320 | */ |
|
4321 | function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
4322 | if( ! is_array( $query_params ) ){ |
|
4323 | 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' ); |
|
4324 | $query_params = array(); |
|
4325 | } |
|
4326 | $query_params['limit'] = 1; |
|
4327 | $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
4328 | if(is_array($copies)){ |
|
4329 | return array_shift($copies); |
|
4330 | }else{ |
|
4331 | return null; |
|
4332 | } |
|
4333 | } |
|
4334 | ||
4335 | ||
4336 |