| @@ 1189-1201 (lines=13) @@ | ||
| 1186 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
|
| 1187 | * @throws \EE_Error |
|
| 1188 | */ |
|
| 1189 | public function get_one($query_params = array()) |
|
| 1190 | { |
|
| 1191 | if (! is_array($query_params)) { |
|
| 1192 | EE_Error::doing_it_wrong('EEM_Base::get_one', |
|
| 1193 | sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), |
|
| 1194 | gettype($query_params)), '4.6.0'); |
|
| 1195 | $query_params = array(); |
|
| 1196 | } |
|
| 1197 | $query_params['limit'] = 1; |
|
| 1198 | $items = $this->get_all($query_params); |
|
| 1199 | if (empty($items)) { |
|
| 1200 | return null; |
|
| 1201 | } else { |
|
| 1202 | return array_shift($items); |
|
| 1203 | } |
|
| 1204 | } |
|
| @@ 5497-5509 (lines=13) @@ | ||
| 5494 | * @return EE_Base_Class |
|
| 5495 | * @throws \EE_Error |
|
| 5496 | */ |
|
| 5497 | public function get_one_copy($model_object_or_attributes_array, $query_params = array()) |
|
| 5498 | { |
|
| 5499 | if (! is_array($query_params)) { |
|
| 5500 | EE_Error::doing_it_wrong('EEM_Base::get_one_copy', |
|
| 5501 | sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), |
|
| 5502 | gettype($query_params)), '4.6.0'); |
|
| 5503 | $query_params = array(); |
|
| 5504 | } |
|
| 5505 | $query_params['limit'] = 1; |
|
| 5506 | $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
| 5507 | if (is_array($copies)) { |
|
| 5508 | return array_shift($copies); |
|
| 5509 | } else { |
|
| 5510 | return null; |
|
| 5511 | } |
|
| 5512 | } |
|