Beispiel #1
0
 public function testPushAndPop()
 {
     $test = new ModelDb('test');
     $select = $test->select();
     var_dump($select);
     $stack = array();
     $this->assertEquals(0, count($stack));
     array_push($stack, 'foo');
     $this->assertEquals('foo', $stack[count($stack) - 1]);
     $this->assertEquals(1, count($stack));
     $this->assertEquals('foo', array_pop($stack));
     $this->assertEquals(0, count($stack));
 }
Beispiel #2
0
 static function sharedInstance()
 {
     if (is_null(self::$sharedInstance)) {
         self::$sharedInstance = new self();
     }
     return self::$sharedInstance;
 }
Beispiel #3
0
function curlBackup($params)
{
    $id = (int) $params['id'];
    $backup = Backup::sharedInstance();
    $modelJob = ModelJob::sharedInstance();
    ini_set("max_execution_time", 0);
    $jobConf = ModelJobConf::sharedInstance()->findById($id)[0];
    $db = ModelDb::sharedInstance()->findById((int) $jobConf->dbId)[0];
    $path = ModelPath::sharedInstance()->findById((int) $jobConf->pathId)[0];
    if (!is_null($jobConf)) {
        $job = new EntityJob();
        $job->jobConfId = $jobConf->id;
        $job->jobConfName = $jobConf->name;
        $job->starttime = time();
        $job->status = "file";
        $job->uploaded = 0;
        $job->deleted = 0;
        $modelJob->save($job);
        // update job status to "file" and save()
        $filename = $backup->backupFiles($path->path, $path->ignored);
        $job->filename = $filename;
        // update job status to "db" and save()
        $job->status = "db";
        $modelJob->save($job);
        $dbfilename = $backup->backupDatabase($db->host, $db->username, $db->pass, $db->dbname);
        $job->dbfilename = $dbfilename;
        // update job status to "cleanup" and save()
        $job->status = "files";
        $modelJob->save($job);
        //$backup->deleteBackups(); //TODO: implement a counter int he config and delete old backups when necessary
        $job->status = "done";
        $job->endtime = time();
        $modelJob->save($job);
        echo "<br/>All done\n";
        //update job status to "complete" or "error" and save()
    }
    exit;
}
Beispiel #4
0
function delete($params)
{
    $id = $params['id'];
    ModelDb::sharedInstance()->deleteById($id);
    ModelJobConf::sharedInstance()->deleteAssociatedJob($id, 'db');
}
Beispiel #5
0
 public static function setConfig($config)
 {
     self::$config = $config;
 }