Overview
Comment: | EntityManager: add a helper method to retrieve an entity from an ID |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 7.3 |
Files: | files | file ages | folders |
SHA1: |
8d72a8244ee64bcc3f2ecc30fc47fb95 |
User & Date: | bohwaz on 2020-02-12 01:24:28 |
Other Links: | branch diff | manifest | tags |
Context
2020-02-12
| ||
01:26 | AbstractEntity: remove "date" pseudo-type, add PHP 7.4 typed properties support check-in: 01d5540763 user: bohwaz tags: 7.3 | |
01:24 | EntityManager: add a helper method to retrieve an entity from an ID check-in: 8d72a8244e user: bohwaz tags: 7.3 | |
01:23 | HTTP root URI: Return exceptions when required data is missing check-in: 6ea68344b2 user: bohwaz tags: 7.3 | |
Changes
Modified src/lib/KD2/DB/EntityManager.php from [e71b565518] to [bf79833570].
︙ | ︙ | |||
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | * @param mixed ...$params Optional parameters to be used in the query * @return null|AbstractEntity */ static public function findOne(string $class, string $query, ...$params) { return self::getInstance($class)->one($query, ...$params); } /** * Formats a SQL query by replacing the table name with the entity table name * @param string $query SQL query * @return string */ protected function formatQuery(string $query): string | > > > > > > > > > > > > | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | * @param mixed ...$params Optional parameters to be used in the query * @return null|AbstractEntity */ static public function findOne(string $class, string $query, ...$params) { return self::getInstance($class)->one($query, ...$params); } /** * Returns an Entity from its ID * @param string $class Entity class name * @param int $id Entity ID * @return null|AbstractEntity */ static public function findOneById(string $class, int $id) { $query = sprintf('SELECT * FROM %s WHERE id = ?;', $class::TABLE); return self::findOne($class, $query, $id); } /** * Formats a SQL query by replacing the table name with the entity table name * @param string $query SQL query * @return string */ protected function formatQuery(string $query): string |
︙ | ︙ |