Skip to content

Commit 30baadc

Browse files
committed
Update #11, Update example
1 parent cb80f10 commit 30baadc

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

examples/example1/app/Model/FileStorage/Drivers/DatabaseDriver.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ public function get($adapter, $path, $cache = false)
2323
return $this->methodResult(false);
2424
}
2525

26-
$row = $this->baseClass->db->select('files', '*', ['file_path' => $path, 'file_adapter' => $adapter])->result();
26+
$row = $this->db->select('files', '*', ['file_path' => $path, 'file_adapter' => $adapter])->result();
2727
if (empty($row['file_id'])) {
2828
return $this->methodResult(false);
2929
}
3030

3131
if ($cache != false) {
3232
if ($cache === true) {
33-
$row['cache'] = $this->baseClass->db->select('file_cache', '*', ['file_id' => $row['file_id']])->results();
33+
$row['cache'] = $this->db->select('file_cache', '*', ['file_id' => $row['file_id']])->results();
3434
} else {
35-
$row['cache'] = $this->baseClass->db->select('file_cache', '*', ['file_cache_path' => $cache])->result();
35+
$row['cache'] = $this->db->select('file_cache', '*', ['file_cache_path' => $cache])->result();
3636
}
3737
}
3838

@@ -54,7 +54,7 @@ public function put($adapter, $path, $mime, $stream = false)
5454
return $this->methodResult(false, ['response' => 'Taki obraz już istnieje']);
5555
}
5656

57-
$getLastInsertId = $this->baseClass->db->pdoQuery('INSERT INTO `files` (`file_adapter`, `file_path`, `file_mime`) VALUES (?,?,?)', [$adapter, $path, $mime])->getLastInsertId();
57+
$getLastInsertId = $this->db->pdoQuery('INSERT INTO `files` (`file_adapter`, `file_path`, `file_mime`) VALUES (?,?,?)', [$adapter, $path, $mime])->getLastInsertId();
5858
return $this->methodResult(true, ['lastInsertId' => $getLastInsertId]);
5959
}
6060

@@ -69,13 +69,13 @@ public function put($adapter, $path, $mime, $stream = false)
6969
*/
7070
public function cache($adapter, $originalPath, $cachePath, $mime, $stream = false)
7171
{
72-
$row = $this->baseClass->db->select('files', '*', ['file_path' => $originalPath])->result();
72+
$row = $this->db->select('files', '*', ['file_path' => $originalPath])->result();
7373
if (empty($row['file_id'])) {
7474
$put = $this->put($adapter, $originalPath, $mime, $stream);
7575
$row['file_id'] = $put['lastInsertId'];
7676
}
7777

78-
$cache = $this->baseClass->db->select('file_cache', '*', ['file_cache_path' => $cachePath])->result();
78+
$cache = $this->db->select('file_cache', '*', ['file_cache_path' => $cachePath])->result();
7979
if (empty($cache['id']) and !empty($row['file_id'])) {
8080
$data = [
8181
'file_id' => $row['file_id'],
@@ -88,7 +88,7 @@ public function cache($adapter, $originalPath, $cachePath, $mime, $stream = fals
8888
// $data['file_cache_metadata'] = json_encode($metadata->get());
8989
// }
9090

91-
$getLastInsertId = $this->baseClass->db->insert('file_cache', $data);
91+
$getLastInsertId = $this->db->insert('file_cache', $data);
9292
return $this->methodResult(true, ['lastInsertId' => $getLastInsertId]);
9393
}
9494

@@ -104,15 +104,15 @@ public function cache($adapter, $originalPath, $cachePath, $mime, $stream = fals
104104
public function drop($adapter, $path)
105105
{
106106
try {
107-
$this->baseClass->db->start();
108-
$row = $this->baseClass->db->pdoQuery('SELECT * FROM files WHERE `file_path` = ?', [$path])->result();
107+
$this->db->start();
108+
$row = $this->db->pdoQuery('SELECT * FROM files WHERE `file_path` = ?', [$path])->result();
109109

110-
$affectedRows = $this->baseClass->db->delete('file_cache', ['file_id' => $row['file_id']])->affectedRows();
111-
$affectedRows = $this->baseClass->db->delete('files', ['file_id' => $row['file_id']])->affectedRows();
110+
$affectedRows = $this->db->delete('file_cache', ['file_id' => $row['file_id']])->affectedRows();
111+
$affectedRows = $this->db->delete('files', ['file_id' => $row['file_id']])->affectedRows();
112112

113-
$this->baseClass->db->end();
113+
$this->db->end();
114114
} catch (\Exception $e) {
115-
$this->baseClass->db->back();
115+
$this->db->back();
116116
return $this->methodResult(false, ['response' => $e->getMessages()]);
117117
}
118118

0 commit comments

Comments
 (0)