Trash All

Trash Table WARNING!!!
511651
public static function trashAll()
  {
    $loadAll = R::findAll(self::classRefactor(get_called_class()));
    R::trashAll($loadAll);
  }
68734
private function cleanUp()
    {
        if ($this->quiet) {
            $errors = explode(PHP_EOL, ob_get_clean());
            $shown = [];

            foreach ($errors as $error) {
                if ($error && !in_array($error, $shown)) {
                    out($error, 'error');
                    $shown[] = $error;
                }
            }
        }

        if (file_exists($this->tmpPharPath)) {
            @unlink($this->tmpPharPath);
        }
        if (file_exists($this->tmpPubkeyPath)) {
            @unlink($this->tmpPharPath);
        }
    }
1038751
protected function trashCurrentItems()
    {
        $trash = $this->entity->getEntityAttributeValueTrash();

        foreach ($this->items as $value) {
            $trash->push($value);
        }
    }
1188808
public function deleteAll() {

        $tablenames = $this->getAllTableNames();
        foreach ($tablenames as $tablename) {
            $this->databaseConnection->query("DROP TABLE " . $tablename);
        }

    }
1053488
public function trash( $args, $assoc_args ) {
		foreach ( $args as $id ) {
			$this->call( $id, __FUNCTION__, 'Trashed', 'Failed trashing' );
		}
	}
1046401
def wipe_db(self):
        """"""
        logger.warning("Wiping the whole database")
        self.client.drop_database(self.db_name)
        logger.debug("Database wiped")
630078
def delete_table(self, table_name):
        
        data = {'TableName': table_name}
        json_input = json.dumps(data)
        return self.make_request('DeleteTable', json_input)
1210071
function() {
        var items = _utils.getArgArray(arguments);
        if (items.length === 0) {
            throw new Error('no files specified to clean up');
        }
        items.forEach(function(item) {
            try {
                var path = (typeof item === 'string') ? item : item.path;
                _fs.unlinkSync(path);
            } catch (e) {
                // Eat the exception.
            }
        });
    }
39874
def purge(self):
        '''
        
        '''
        for table_name in self._db.list_tables():
            self._db.flush(table_name)

        self._run_init_queries()
1148155
protected function cleanupMongoDB()
    {
        try {
            $this->dbh->drop();
        } catch (\MongoDB\Driver\Exception $e) {
            throw new \Exception(sprintf('Failed to drop the DB: %s', $e->getMessage()));
        }
    }
1090360
def purge_table(self, name):
        
        if name in self._table_cache:
            del self._table_cache[name]

        proxy = StorageProxy(self._storage, name)
        proxy.purge_table()
822218
function trashOrUntrashPages(cb) {
          const ids = tree.map(p => p._id);
          return self.apos.docs.db.update({ _id: { $in: ids } }, action, {
            multi: true
          }, (err, res) => {
            cb(err);
          });
        }
138730
def do_rmall(self, line):
        ""
        args = self.getargs(line)
        if args and args[-1] == "yes":
            args.pop()

            if not args:
                args = [self.table.name]

            while args:
                table = self.conn.get_table(args.pop(0))
                print "from table " + table.name

                for item in table.scan(attributes_to_get=[], request_limit=10):
                    print "  removing %s" % item
                    item.delete()
        else:
            print "ok, never mind..."
1304177
def delete(self, table):
        
        self._table = table
        self._limit = None
        self._query = "DELETE FROM {0}".format(self._table)

        return self
958339
def cleanup():
    """"""
    for sck in list(Wdb._sockets):
        try:
            sck.close()
        except Exception:
            log.warn('Error in cleanup', exc_info=True)
1216499
public function cleanup($table)
    {
        $this->checkTable($table);

        if (!$this->param('dry-run')) {
            $okayToDestroy = $this->in(__('Are you sure? This will irreversibly delete files'), ['y', 'n'], 'n');
            if ($okayToDestroy === 'N') {
                $this->out(__('Aborted, no files deleted.'));
                $this->_stop();
            }
        } else {
            $this->out(__('<info>Performing dry run cleanup.</info>'));
            $this->out($this->nl(0));
        }

        $config = $this->Table->behaviors()->Proffer->config();

        // Get the root upload folder for this table
        $uploadFieldFolders = glob(WWW_ROOT . 'files' . DS . strtolower($table) . DS . '*');

        // Loop through each upload field configured for this table (field)
        foreach ($uploadFieldFolders as $fieldFolder) {
            // Loop through each instance of an upload for this field (seed)
            $pathFieldName = pathinfo($fieldFolder, PATHINFO_BASENAME);
            $uploadFolders = glob($fieldFolder . DS . '*');
            foreach ($uploadFolders as $seedFolder) {
                // Does the seed exist in the db?
                $seed = pathinfo($seedFolder, PATHINFO_BASENAME);

                foreach ($config as $field => $settings) {
                    if ($pathFieldName != $field) {
                        continue;
                    }

                    $targets = [];

                    $record = $this->{$this->Table->alias()}->find()
                        ->select([
                            $field,
                            $settings['dir']
                        ])
                        ->where([
                            $settings['dir'] => $seed
                        ])
                        ->first();

                    if ($record) {
                        $record = $record->toArray();
                    } else {
                        $record = [];
                    }

                    if (!in_array($seed, $record)) {
                        // No it doesn't - remove the folder and it's contents - probably with a user prompt
                        if ($this->param('dry-run')) {
                            if ($this->param('verbose')) {
                                $this->out(__("Would remove folder `$seedFolder`"));
                            } else {
                                $this->out(__("Would remove folder `$seed`"));
                            }
                        } else {
                            array_map('unlink', glob($seedFolder . DS . '*'));
                            rmdir($seedFolder);

                            if ($this->param('verbose')) {
                                $this->out(__("Remove `$seedFolder` folder and contents"));
                            } else {
                                $this->out(__("Removed `$seed` folder and contents"));
                            }
                        }
                    } else {
                        $files = glob($seedFolder . DS . '*');

                        $filenames = array_map(function ($p) {
                            return pathinfo($p, PATHINFO_BASENAME);
                        }, $files);

                        $targets[] = $record[$field];
                        if (!empty($settings['thumbnailSizes'])) {
                            foreach ($settings['thumbnailSizes'] as $prefix => $dimensions) {
                                $targets[] = $prefix . '_' . $record[$field];
                            }
                        }

                        $filesToRemove = array_diff($filenames, $targets);

                        foreach ($filesToRemove as $file) {
                            if ($this->param('dry-run') && $this->param('verbose')) {
                                $this->out(__("Would delete `$seedFolder" . DS . "$file`"));
                            } elseif ($this->param('dry-run')) {
                                $this->out(__("Would delete `$file`"));
                            } else {
                                unlink($seedFolder . DS . $file);
                                if ($this->param('verbose')) {
                                    $this->out(__("Deleted `$seedFolder" . DS . "$file`"));
                                } else {
                                    $this->out(__("Deleted `$file`"));
                                }
                            }
                        }
                    }
                }
            }
        }

        $this->out($this->nl(0));
        $this->out(__('<info>Completed</info>'));
    }
50977
static function cleanup()
    {
        $ini = eZINI::instance();
        $db = eZDB::instance();
        $timeFrame = 1;
        if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) )
            $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' );
        $time = time() - $timeFrame * 3600;

        $db->query( "DELETE FROM eztipafriend_request
                      WHERE created < $time " );
    }