mirror of
https://github.com/silverstripe/silverstripe-environmentcheck
synced 2024-10-22 17:05:40 +02:00
29 lines
735 B
PHP
29 lines
735 B
PHP
|
<?php
|
||
|
/**
|
||
|
* This file contains a number of default environment checks that you can use.
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Check that the connection to the database is working, by looking for records in some table.
|
||
|
* By default, Member will be checked.
|
||
|
*
|
||
|
* @param $checkTable The table that will be checked.
|
||
|
*/
|
||
|
class DatabaseCheck implements EnvironmentCheck {
|
||
|
protected $checkTable;
|
||
|
|
||
|
function __construct($checkTable = "Member") {
|
||
|
$this->checkTable = $checkTable;
|
||
|
}
|
||
|
|
||
|
function check() {
|
||
|
$count = DB::query("SELECT COUNT(*) FROM \"$this->checkTable\"")->value();
|
||
|
|
||
|
if($count > 0) {
|
||
|
return array(EnvironmentCheck::OK, "");
|
||
|
} else {
|
||
|
return array(EnvironmentCheck::WARNING, "$this->checkTable queried ok but has no records");
|
||
|
}
|
||
|
}
|
||
|
}
|