@@ -1943,76 +1943,6 @@ public function deleteDocument(string $collection, string $id): bool
19431943 return $ deleted ;
19441944 }
19451945
1946- /**
1947- * Delete Documents
1948- *
1949- * @param string $collection
1950- * @param array<string> $internalIds
1951- * @param array<string> $permissionIds
1952- *
1953- * @return int
1954- */
1955- public function deleteDocuments (string $ collection , array $ internalIds , array $ permissionIds ): int
1956- {
1957- if (empty ($ internalIds )) {
1958- return 0 ;
1959- }
1960-
1961- try {
1962- $ name = $ this ->filter ($ collection );
1963-
1964- $ sql = "
1965- DELETE FROM {$ this ->getSQLTable ($ name )}
1966- WHERE _id IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ internalIds ))) . ")
1967- {$ this ->getTenantQuery ($ collection )}
1968- " ;
1969-
1970- $ sql = $ this ->trigger (Database::EVENT_DOCUMENTS_DELETE , $ sql );
1971-
1972- $ stmt = $ this ->getPDO ()->prepare ($ sql );
1973-
1974- foreach ($ internalIds as $ id => $ value ) {
1975- $ stmt ->bindValue (":_id_ {$ id }" , $ value );
1976- }
1977-
1978- if ($ this ->sharedTables ) {
1979- $ stmt ->bindValue (':_tenant ' , $ this ->tenant );
1980- }
1981-
1982- if (!$ stmt ->execute ()) {
1983- throw new DatabaseException ('Failed to delete documents ' );
1984- }
1985-
1986- if (!empty ($ permissionIds )) {
1987- $ sql = "
1988- DELETE FROM {$ this ->getSQLTable ($ name . '_perms ' )}
1989- WHERE _document IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ permissionIds ))) . ")
1990- {$ this ->getTenantQuery ($ collection )}
1991- " ;
1992-
1993- $ sql = $ this ->trigger (Database::EVENT_PERMISSIONS_DELETE , $ sql );
1994-
1995- $ stmtPermissions = $ this ->getPDO ()->prepare ($ sql );
1996-
1997- foreach ($ permissionIds as $ id => $ value ) {
1998- $ stmtPermissions ->bindValue (":_id_ {$ id }" , $ value );
1999- }
2000-
2001- if ($ this ->sharedTables ) {
2002- $ stmtPermissions ->bindValue (':_tenant ' , $ this ->tenant );
2003- }
2004-
2005- if (!$ stmtPermissions ->execute ()) {
2006- throw new DatabaseException ('Failed to delete permissions ' );
2007- }
2008- }
2009- } catch (\Throwable $ e ) {
2010- throw new DatabaseException ($ e ->getMessage (), $ e ->getCode (), $ e );
2011- }
2012-
2013- return $ stmt ->rowCount ();
2014- }
2015-
20161946 /**
20171947 * Find Documents
20181948 *
0 commit comments