示例#1
0
文件: tareas.php 项目: jesusgm/tareas
 function stop()
 {
     if ($this->estado == 1) {
         //solo se puede parar si esta en curso
         //obtener el tiempo en curso de la tarea actual
         $tiempo = new Tiempo();
         $db = new conexion();
         $sql = "SELECT * FROM " . $tiempo->tabla . " \n\t\t\t\t\t\tWHERE id_tarea = " . $this->id . " AND \n\t\t\t\t\t\t\t\tfin = '0000-00-00 00:00:00'";
         $t = $db->select($sql);
         $tiempo2 = new Tiempo($t[0]['id']);
         $tiempo2->parar();
         $this->setEstado(0);
         $this->dbsave();
         return $this->getTiempos();
     }
 }
示例#2
0
    }
    function dump($institucion)
    {
        $rutaArchivo = $this->rutaDirectorio . '/' . $institucion . '_' . date('dmYHis') . '.backup';
        $comando = '"' . $this->rutaPgDump . '" --host 192.168.1.1 --port 5432 --username "edalmava" --no-password  --format custom --blobs --file "' . $rutaArchivo . '" "' . $institucion . '"';
        system($comando, $retVal);
        return $retVal;
    }
    function dumpInstituciones($instituciones)
    {
        foreach ($instituciones as $institucion) {
            echo "{$institucion}: ";
            echo !$this->dump($institucion) ? "[OK]\n" : "[ERROR]\n";
        }
    }
}
$instituciones = array('colegio1', 'colegio2', 'colegio3');
echo "************************************************************\n";
echo "*     Programa para Backup de base de datos PostgreSQL     *\n";
echo "************************************************************\n";
echo "\n\n";
try {
    $backup = new Backup('D:/BD/' . date('dmY'), 'C:/Program Files/PostgreSQL/9.4/bin\\pg_dump.exe');
    $tiempo = new Tiempo();
    $backup->dumpInstituciones($instituciones);
    $tiempo->setTiempoFinal();
    echo "\n\n";
    echo "Tiempo empleado: ({$tiempo->getTiempoSeg()}seg) ({$tiempo->getTiempoMin()}min)";
} catch (Exception $e) {
    echo "ERROR: " . $e->getMessage() . "\n";
}