Skip to content

Commit

Permalink
[VD:MySQL] fix #2164, fix #2166 problem with MySQL > 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Aug 25, 2017
1 parent 64f3d52 commit 02ae12f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions php/MySQLStorage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
9 changes: 4 additions & 5 deletions php/elFinderVolumeMySQL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 02ae12f

Please sign in to comment.