diff options
Diffstat (limited to 'core/namespace/Page')
-rw-r--r-- | core/namespace/Page/Item.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/namespace/Page/Item.php b/core/namespace/Page/Item.php index d559b81..d875e8a 100644 --- a/core/namespace/Page/Item.php +++ b/core/namespace/Page/Item.php @@ -27,16 +27,24 @@ class Item extends \Item { } #=============================================================================== - # Return unique page IDs for search results + # Return search results as Page\Attribute #=============================================================================== - public static function getSearchResultIDs($search, \Database $Database): array { - $Statement = $Database->prepare(sprintf("SELECT id FROM %s WHERE + public static function getSearchResults($search, \Database $Database): array { + $Statement = $Database->prepare(sprintf("SELECT * FROM %s WHERE MATCH(name, body) AGAINST(? IN BOOLEAN MODE) LIMIT 20", Attribute::TABLE)); if($Statement->execute([$search])) { - return $Statement->fetchAll($Database::FETCH_COLUMN); + return $Statement->fetchAll($Database::FETCH_CLASS, 'Page\Attribute'); } return []; } + + #=============================================================================== + # Return associated User\Attribute + #=============================================================================== + public function getUserAttribute() { + $Statement = $this->Database->query(sprintf('SELECT * FROM user WHERE id = %d', $this->Attribute->get('user'))); + return $Statement->fetchObject('User\Attribute'); + } } |