You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
There doesn't seem to be a way to sort results by update or create time. This is useful for queries where I'd like to get the most recent changed files.
The text was updated successfully, but these errors were encountered:
require_once ('vendor/autoload.php');
use \Filebase\Database;
$database = new Database([
'dir' => 'storage/user',
'backupLocation' => 'storage/backup'
]);
// Get all data (way 1)
$list = $database->findAll();
// or get all data with query (way 2)
$list = $database->query()
->limit(10)
->resultDocuments();
// Create new array sort the list
foreach ($list as $key => $item) {
$resort[$key] = $item->createdAt();
}
// Re-sorting list
array_multisort($resort, SORT_DESC, $list);
// Echo the sorted list
foreach($list as $key => $item) {
echo $key.'. '.$item->getId().' | '.$item->createdAt().' | '.$item->updatedAt().'<br>';
}
Note:
Way 1 is not efficient.
Way 2 is better, because you are able to use cache.
sumpygump
pushed a commit
to sumpygump/Filebase
that referenced
this issue
Feb 8, 2019
There doesn't seem to be a way to sort results by update or create time. This is useful for queries where I'd like to get the most recent changed files.
The text was updated successfully, but these errors were encountered: