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)); }
static function sharedInstance() { if (is_null(self::$sharedInstance)) { self::$sharedInstance = new self(); } return self::$sharedInstance; }
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; }
function delete($params) { $id = $params['id']; ModelDb::sharedInstance()->deleteById($id); ModelJobConf::sharedInstance()->deleteAssociatedJob($id, 'db'); }
public static function setConfig($config) { self::$config = $config; }