memories/lib/Db/TimelineWriteOrphans.php

33 lines
724 B
PHP
Raw Normal View History

2023-02-09 05:55:12 +00:00
<?php
declare(strict_types=1);
namespace OCA\Memories\Db;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
trait TimelineWriteOrphans
{
protected IDBConnection $connection;
/**
* Mark all files in the table as orphaned.
*
* @return int Number of rows affected
*/
public function orphanAll(): int
{
$do = function (string $table) {
$query = $this->connection->getQueryBuilder();
$query->update($table)
->set('orphan', $query->createNamedParameter(true, IQueryBuilder::PARAM_BOOL))
;
2023-02-09 05:55:12 +00:00
return $query->executeStatement();
};
return $do('memories') + $do('memories_livephoto');
2023-02-09 05:55:12 +00:00
}
}