コード例 #1
0
 private function getFilePath(File $file)
 {
     $storagePath = __DIR__ . '/../../files/' . date('Y/m/d', strtotime($file->getCreatedAt()));
     if (!is_dir($storagePath)) {
         mkdir($storagePath, 0777, true);
     }
     return $storagePath . '/' . $file->getId();
 }
コード例 #2
0
 public function add(File $file)
 {
     $statement = $this->pdo->prepare('INSERT INTO file (id, path, created_at) VALUES (:id, :path, :created_at)');
     $statement->execute(['id' => $file->getId(), 'path' => $file->getPath(), 'created_at' => $file->getCreatedAt()]);
     return true;
 }