bcom/clazz/MegaFile.class.php

47 lines
1.2 KiB
PHP

<?php
class MegaFile{
protected $ID;
protected $where;
protected $args;
public function __construct($where,$args = array()){
$this->where = $where;
$this->args = $args;
}
public function is(){
$req = $GLOBALS['bdd']->prepare('SELECT COUNT(ID) AS count FROM megaFile WHERE ' . $where);//TODO changeto megaFileSSSSS
$req->execute($args);
return !!$req->fetch();
}
public static function addVersionFile($version,$fileType,$publicy){
try {
$path = '/Root/bernard.com/projets/' .
$version->getProject()->getName() . '/' .
$version->getLanguage()->getName() . '/' .
$version->getName().'/';
$pathFile = MegaFile::getFromPath($path);
if($pathFile->is())
return USED_PATH;
$pathFile = new MegaFile('fileType=? AND ');
if($pathFile->is())
return USED_PATH;
$req = $GLOBALS['bdd']->prepare('INSERT INTO megaFile (fileType,path,publicy) VALUES (?,?,?)');//TODO changeto megaFileSSSSS
$req->execute(array($fileType,$path,$publicy));
}catch(NoneObjectCallException $e){
return NONE_VERSION;
}
}
public static function getFromPath($path){
return new MegaFile('path=?',array($path));
}
public const NONE_VERSION = "sshfzrgh";
}