@@ 30-45 (lines=16) @@ | ||
27 | parent::__construct($database, 'users', User::class); |
|
28 | } |
|
29 | ||
30 | public function lookupByScreenName($screen_name, $params = []) |
|
31 | { |
|
32 | $_screen_name = (string) $screen_name; |
|
33 | if (strlen($_screen_name) >= User::SCREEN_NAME_MINIMUM_LENGTH) { |
|
34 | $statement = $this->database()->prepare(" |
|
35 | SELECT * |
|
36 | FROM `" . $this->databaseTable() . "` |
|
37 | WHERE |
|
38 | `screen_name` = :screen_name |
|
39 | "); |
|
40 | if ($statement->execute(['screen_name' => $_screen_name])) { |
|
41 | return $this->instantiateObject($statement->fetch(), $params); |
|
42 | } |
|
43 | } |
|
44 | return null; |
|
45 | } |
|
46 | } |
|
47 |
@@ 337-351 (lines=15) @@ | ||
334 | * |
|
335 | * @return AbstractObject|null `NULL` if the object is not found or cannot be deleted |
|
336 | */ |
|
337 | public function delete($id, $params = []) |
|
338 | { |
|
339 | $object = $this->getDeletedObject($id, $params); |
|
340 | if ($object instanceof AbstractObject) { |
|
341 | $statement = $this->database()->prepare(" |
|
342 | DELETE FROM `" . $this->databaseTable() . "` |
|
343 | WHERE |
|
344 | `id` = :id |
|
345 | "); |
|
346 | if ($statement->execute(['id' => $id])) { |
|
347 | return $object; |
|
348 | } |
|
349 | } |
|
350 | return null; |
|
351 | } |
|
352 | ||
353 | /** |
|
354 | * Retrieve a soon-to-be deleted object from database |