/**
  * @return TPDocumento
  * @param string $digital
  * @param Base $persist
  */
 public function registerPNGDB($digital, $persist)
 {
     $pngs = $this->listPNG($digital);
     $repository = $this->generateRepositoryForDigital($digital);
     $next = -1;
     $query = 'INSERT INTO TB_DOCUMENTOS_IMAGEM (DIGITAL,FLG_PUBLICO,MD5,DES_HASH_FILE,IMG_WIDTH,IMG_HEIGHT,IMG_BYTES,IMG_TYPE,ORDEM,ID_USUARIO,ID_UNIDADE) VALUES ';
     foreach ($pngs as $png) {
         $query .= '(?,?,?,?,?,?,?,?,?,?,?),';
         $md5 = CFUtils::random();
         rename("{$repository}/{$png}", "{$repository}/{$md5}.png");
         $information = getimagesize("{$repository}/{$md5}.png");
         $row[] = $digital;
         $row[] = 1;
         $row[] = $md5;
         $row[] = hash_file('md5', "{$repository}/{$md5}.png");
         $row[] = $information[0];
         $row[] = $information[1];
         $row[] = filesize("{$repository}/{$md5}.png");
         $row[] = 8;
         $row[] = ++$next;
         $row[] = Controlador::getInstance()->usuario->ID;
         $row[] = Controlador::getInstance()->usuario->ID_UNIDADE;
     }
     $stmt = $persist->prepare(trim($query, ','));
     $stmt->execute($row);
     return $this;
 }
Esempio n. 2
0
 /**
  * @return void
  */
 protected function __construct()
 {
     $configuration = CFUtils::parseIniFile(CF_APP_BASE_PATH . '/cfg/configuration.ini');
     $this->_params = $configuration[CF_APP_ENVIRONMENT];
 }