| @@ 1208-1220 (lines=13) @@ | ||
| 1205 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
|
| 1206 | * @throws \EE_Error |
|
| 1207 | */ |
|
| 1208 | public function get_one($query_params = array()) |
|
| 1209 | { |
|
| 1210 | if (! is_array($query_params)) { |
|
| 1211 | EE_Error::doing_it_wrong('EEM_Base::get_one', |
|
| 1212 | sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), |
|
| 1213 | gettype($query_params)), '4.6.0'); |
|
| 1214 | $query_params = array(); |
|
| 1215 | } |
|
| 1216 | $query_params['limit'] = 1; |
|
| 1217 | $items = $this->get_all($query_params); |
|
| 1218 | if (empty($items)) { |
|
| 1219 | return null; |
|
| 1220 | } else { |
|
| 1221 | return array_shift($items); |
|
| 1222 | } |
|
| 1223 | } |
|
| @@ 5536-5548 (lines=13) @@ | ||
| 5533 | * @return EE_Base_Class |
|
| 5534 | * @throws \EE_Error |
|
| 5535 | */ |
|
| 5536 | public function get_one_copy($model_object_or_attributes_array, $query_params = array()) |
|
| 5537 | { |
|
| 5538 | if (! is_array($query_params)) { |
|
| 5539 | EE_Error::doing_it_wrong('EEM_Base::get_one_copy', |
|
| 5540 | sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), |
|
| 5541 | gettype($query_params)), '4.6.0'); |
|
| 5542 | $query_params = array(); |
|
| 5543 | } |
|
| 5544 | $query_params['limit'] = 1; |
|
| 5545 | $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
| 5546 | if (is_array($copies)) { |
|
| 5547 | return array_shift($copies); |
|
| 5548 | } else { |
|
| 5549 | return null; |
|
| 5550 | } |
|
| 5551 | } |
|