public static function write($file, $content, $mode = 0666)
{
static::createDir(dirname($file));
if (@file_put_contents($file, $content) === FALSE) {
// @ is escalated to exception
throw new Nette\IOException("Unable to write file '{$file}'.");
}
if ($mode !== NULL && !@chmod($file, $mode)) {
// @ is escalated to exception
throw new Nette\IOException("Unable to chmod file '{$file}'.");
}
}
/** * backup single database table to file * * @param string $table * @param string $path */ public function backupTableToFile(string $table, string $path) { $sql = $this->getHeader(); $sql .= $this->backupTable($table); FileSystem::createDir($path); $path .= '/' . $table . '_' . date('Y-m-d_H-i-s') . '.sql'; FileSystem::write($path, $sql); }