Gets the results from the last automated backup that was run based upon
the statuses of the courses that were looked at.

@global moodle_database $DB
@return array
163285
public static function get_backup_status_array() {
        global $DB;

        $result = array(
            self::BACKUP_STATUS_ERROR => 0,
            self::BACKUP_STATUS_OK => 0,
            self::BACKUP_STATUS_UNFINISHED => 0,
            self::BACKUP_STATUS_SKIPPED => 0,
            self::BACKUP_STATUS_WARNING => 0,
            self::BACKUP_STATUS_NOTYETRUN => 0
        );

        $statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');

        foreach ($statuses as $status) {
            if (empty($status->statuscount)) {
                $status->statuscount = 0;
            }
            $result[(int)$status->laststatus] += $status->statuscount;
        }

        return $result;
    }
933092
public function getAllForInsertUpdate()
    {
        $data = [];
        foreach ($this->_values as $key => $value) {
            if ($key === '_id' || $key === '_rev') {
                continue;
            }

            if ($key === '_key' && $value === null) {
                // key value not yet set
                continue;
            }
            $data[$key] = $value;
        }
        if ($this->_key !== null) {
            $data['_key'] = $this->_key;
        }

        return $data;
    }
1173971
public function get()
    {
        $rows = [];

        foreach ($this->db as $key => $value) {
            $rows[] = (object) [
                'key'   => $key,
                'value' => is_string($value) ? $value : print_r($value, true),
            ];
        }

        return $rows;
    }
430902
public function getStatuses()
    {
        $schedules = clone $this->getCollection()
            ->setOrder('status', Zend_Db_Select::SQL_ASC);
        $schedules->getSelect()
            ->group('status')
            ->reset(Zend_Db_Select::COLUMNS)
            ->columns('status');
        $statuses = $schedules->getConnection()
            ->fetchCol($schedules->getSelect());
        $statusArray = array();
        foreach ($statuses as $status) {
            $statusArray[$status] = $status;
        }
        return $statusArray;
    }
833830
protected function databaseInfo()
    {
        $pdo = $this->database->getConnection()->getPdo();

        $version = $this->ifExists($pdo->getAttribute(PDO::ATTR_SERVER_VERSION));

        $driver = $this->ifExists($pdo->getAttribute(PDO::ATTR_DRIVER_NAME));
        $driver = $this->ifExists((! empty($this->databases[$driver]) ? $this->databases[$driver] : null));

        $this->results['database'] = compact('driver', 'version');

        return $this;
    }
1060078
public function listDBs() {

        $databases = [];

        foreach (new \DirectoryIterator($this->path) as $fileInfo) {
            if (\preg_match('/\.sqlite$/', $fileInfo->getFilename())) {
                $databases[] = \str_replace('.sqlite', '', $fileInfo->getFilename());
             }
        }

        return $databases;
    }
271225
public function getLast()
    {
        $query = $this->table()->where('batch', $this->getLastBatchNumber());

        return $query->orderBy('migration', 'desc')->get()->all();
    }
398527
public function backups()
    {
        //Only admins can access this controller
        if (!$this->Auth->isGroup('admin')) {
            return;
        }

        $links[] = [__d('me_cms', 'List backups'), [
            'controller' => 'Backups',
            'action' => 'index',
            'plugin' => 'MeCms',
            'prefix' => ADMIN_PREFIX,
        ]];
        $links[] = [__d('me_cms', 'Add backup'), [
            'controller' => 'Backups',
            'action' => 'add',
            'plugin' => 'MeCms',
            'prefix' => ADMIN_PREFIX,
        ]];

        return [$links, __d('me_cms', 'Backups'), ['icon' => 'database']];
    }
419618
public function getDb()
    {
        if (!$this->db) {
            $this->db = Bootstrap::getSingleton()->getDatabase();
        }
        return $this->db;
    }
83659
public function getForDynamoDB()
    {
        $parameters = parent::getForDynamoDB();

        $rangeCondition = $this->rangeCondition;
        if (null !== $rangeCondition) {
            $parameters['RangeKeyCondition'] = $rangeCondition->getForDynamoDB();
        }

        $scanIndexForward = $this->scanIndexForward;
        if (null !== $scanIndexForward) {
            $parameters['ScanIndexForward'] = $scanIndexForward;
        }

        return $parameters;
    }
452454
public function exportDatabases()
    {
        $exports = [];
        foreach ($this->databases as $db) {
            $exports[] = $this->createExport($db);
        }

        return $exports;
    }
852632
public function getDatabases() {
		$client = $this->getClient();

		if ($this->_profilerEnabled) {
			$event = $this->getProfiler()->startRead('Databases list');
		}

		$databasesRaw = $client->listDBs();

		if ($this->_profilerEnabled) {
			$event->stopSuccess();
		}

		$databases = [];

		foreach ($databasesRaw['databases'] as $database) {
			$databases[] = $database['name'];
		}

		return $databases;
	}
1309149
public function get_courserecord() {
        global $DB;

        if ($this->courserecord == null) {
            $this->courserecord = $DB->get_record('course', array('id' => $this->properties->course));
        }
        return $this->courserecord;
    }
1118691
public function get_activities() {
        $modinfo = get_fast_modinfo($this->course);
        $result = array();
        foreach ($modinfo->get_cms() as $cm) {
            if ($cm->completion != COMPLETION_TRACKING_NONE && !$cm->deletioninprogress) {
                $result[$cm->id] = $cm;
            }
        }
        return $result;
    }
412729
public static function getLast() {
		
		$class = get_called_class();

		// check about single primary key
		if ($class::hasCompoundKey()) {
			return NULL;
		}
		
		// check if auto-increment key
		$db = Database::getInstance();
		if (!$db->isAutoIncrement($class::TABLE_NAME)) {
			return NULL;
		}
		
		// cast to string
		$tableKey = (is_array($class::TABLE_KEY) and array_key_exists(0, $class::TABLE_KEY)) ? $class::TABLE_KEY[0] : $class::TABLE_KEY;

		$db->setQuery('SELECT * FROM `' . $class::TABLE_NAME . '` ORDER BY `' . $tableKey . '` DESC LIMIT 1');
		$obj = $db->loadObject();

		return (is_a($obj, 'stdClass') ? new $class($obj) : NULL);
		
	}
613802
public function getAll()
    {
        if (!$this->isDataLoadedFromDb) {
            $stmt = $this->db->prepare('SELECT * FROM ' . $this->name);
            $stmt->execute();

            while ($row = $stmt->fetch(\PDO::FETCH_NUM, \PDO::FETCH_ORI_NEXT)) {
                $this->data[$row[0]] = $row[1];
            }
        }

        return $this->data;
    }
595656
public function getNbResults()
    {
        if (isset($this->nbResults)) {
            return $this->nbResults;
        }

        $countQuery = clone $this->query;
        $countQuery->limit = 0;

        return $this->nbResults = $this->trashService->findTrashItems($countQuery)->count;
    }