本文整理汇总了PHP中filesystem::rm方法的典型用法代码示例。如果您正苦于以下问题:PHP filesystem::rm方法的具体用法?PHP filesystem::rm怎么用?PHP filesystem::rm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filesystem
的用法示例。
在下文中一共展示了filesystem::rm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sha1
/**
* 文件哈希
*/
public function sha1()
{
$file = $this->file('file');
if (intval($file['size']) <= 0) {
return;
}
$tmp = sharePHP::get_application_dir() . 'tmp/';
$extension = substr($file['name'], strrpos($file['name'], '.') + 1);
filesystem::mkdir($tmp);
$filename = $tmp . '1.' . $extension;
move_uploaded_file($file['tmp_name'], $filename);
$result = sha1_file($filename);
filesystem::rm($tmp);
view::assign('result', $result);
}
示例2: backup
/**
* 备份
* @param $filename 文件名
* @param $db 数据库名(默认当前库)
* @param $table 数据表名(默认为所有表)
* @param $backup_data 是否备份数据(默认只备份数据结构)
*/
public function backup($filename, $db = '', $table = '', $backup_data = false)
{
filesystem::rm($filename);
if ($db) {
$this->db_name = $db;
$this->mysqli->select_db($this->db_name);
}
set_time_limit(0);
$table = $this->mysqli->query('show tables') or die($this->show_error());
$temp_dir = sys_get_temp_dir();
while ($t = $table->fetch_assoc()) {
$table_name = '`' . $this->db_name . '`.`' . $t['Tables_in_' . $this->db_name] . '`';
$rs_ = $this->mysqli->query('show create table ' . $table_name) or die($this->show_error());
while ($row = $rs_->fetch_assoc()) {
$rs = $row;
}
$data = $rs['Create Table'] . ";\r\n\r\n";
if ($backup_data) {
$result = $this->mysqli->query('show columns from ' . $table_name) or die($this->show_error());
$insert = 'insert into ' . $t['Tables_in_' . $this->db_name] . ' (';
while ($row = $result->fetch_assoc()) {
$insert .= '`' . $row['Field'] . '`,';
}
$result->free_result();
$insert = substr($insert, 0, -1);
$insert .= ') values ';
$result = $this->mysqli->query('select * from ' . $table_name) or die($this->show_error());
$i = 0;
while ($row = $result->fetch_assoc()) {
$insert .= '(';
foreach ($row as $r) {
$insert .= '\'' . trim(addslashes($r)) . '\',';
}
$insert = substr($insert, 0, -1);
$insert .= '),';
$i += 1;
}
$result->free_result();
if ($i > 0) {
$data .= substr($insert, 0, -1) . ";\r\n\r\n";
}
}
$data = preg_replace('/(?i)AUTO_INCREMENT=\\d+\\s+/', '', $data);
filesystem::write($filename, $data, true);
}
}