diff --git a/php/MySQLStorage.sql b/php/MySQLStorage.sql index 67a33ecd62..4b0b323ece 100644 --- a/php/MySQLStorage.sql +++ b/php/MySQLStorage.sql @@ -5,14 +5,14 @@ CREATE TABLE IF NOT EXISTS `elfinder_file` ( `name` varchar(256) NOT NULL, `content` longblob NOT NULL, `size` int(10) unsigned NOT NULL default '0', - `mtime` int(10) unsigned NOT NULL, + `mtime` int(10) unsigned NOT NULL default '0', `mime` varchar(256) NOT NULL default 'unknown', `read` enum('1', '0') NOT NULL default '1', `write` enum('1', '0') NOT NULL default '1', `locked` enum('1', '0') NOT NULL default '0', `hidden` enum('1', '0') NOT NULL default '0', - `width` int(5) NOT NULL, - `height` int(5) NOT NULL, + `width` int(5) NOT NULL default '0', + `height` int(5) NOT NULL default '0', PRIMARY KEY (`id`), UNIQUE KEY `parent_name` (`parent_id`, `name`), KEY `parent_id` (`parent_id`) diff --git a/php/elFinderVolumeMySQL.class.php b/php/elFinderVolumeMySQL.class.php index 8a4d3c5daf..fab57d0a32 100644 --- a/php/elFinderVolumeMySQL.class.php +++ b/php/elFinderVolumeMySQL.class.php @@ -208,8 +208,8 @@ protected function query($sql) { * @author Dmitry (dio) Levashov **/ protected function make($path, $name, $mime) { - $sql = 'INSERT INTO %s (`parent_id`, `name`, `size`, `mtime`, `mime`, `content`, `read`, `write`) VALUES (\'%s\', \'%s\', 0, %d, \'%s\', \'\', \'%d\', \'%d\')'; - $sql = sprintf($sql, $this->tbf, $path, $this->db->real_escape_string($name), time(), $mime, $this->defaults['read'], $this->defaults['write']); + $sql = 'INSERT INTO %s (`parent_id`, `name`, `size`, `mtime`, `mime`, `content`, `read`, `write`, `locked`, `hidden`, `width`, `height`) VALUES (\'%s\', \'%s\', 0, %d, \'%s\', \'\', \'%d\', \'%d\', \'%d\', \'%d\', 0, 0)'; + $sql = sprintf($sql, $this->tbf, $path, $this->db->real_escape_string($name), time(), $mime, $this->defaults['read'], $this->defaults['write'], $this->defaults['locked'], $this->defaults['hidden']); // echo $sql; return $this->query($sql) && $this->db->affected_rows > 0; } @@ -232,7 +232,7 @@ protected function cacheDir($path) { FROM '.$this->tbf.' AS f LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\' WHERE f.parent_id=\''.$path.'\' - GROUP BY f.id'; + GROUP BY f.id, ch.id'; $res = $this->query($sql); if ($res) { @@ -526,10 +526,9 @@ protected function _inpath($path, $parent) { protected function _stat($path) { $sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs FROM '.$this->tbf.' AS f - LEFT JOIN '.$this->tbf.' AS p ON p.id=f.parent_id LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime=\'directory\' WHERE f.id=\''.$path.'\' - GROUP BY f.id'; + GROUP BY f.id, ch.id'; $res = $this->query($sql);