src/Model/CachableModel.php
protected static function databaseIsReady()
    {
        $object = DataObject::singleton(static::class);

        // if any of the tables aren't created in the database
        $table = $object->baseTable();
        if (!ClassInfo::hasTable($table)) {
            return false;
        }

        // if any of the tables don't have all fields mapped as table columns
        $dbFields = DB::field_list($table);
        if (!$dbFields) {
            return false;
        }

        $objFields = $object->getSchema()->databaseFields($object, false);
        $missingFields = array_diff_key($objFields, $dbFields);

        if ($missingFields) {
            return false;
        }

        return true;
    }
protected static function databaseIsReady()
    {
        $object = DataObject::singleton(static::class);

        // if any of the tables aren't created in the database
        $table = $object->baseTable();
        if (!ClassInfo::hasTable($table)) {
            return false;
        }

        // if any of the tables don't have all fields mapped as table columns
        $dbFields = DB::field_list($table);
        if (!$dbFields) {
            return false;
        }

        $objFields = $object->getSchema()->databaseFields($object, false);
        $missingFields = array_diff_key($objFields, $dbFields);

        if ($missingFields) {
            return false;
        }

        return true;
    }
protected static function databaseIsReady ( ) { $ object = DataObject :: singleton ( static :: class ) ; // if any of the tables aren't created in the database $ table = $ object -> baseTable ( ) ; if ( ! ClassInfo :: hasTable ( $ table ) ) { return false ; } // if any of the tables don't have all fields mapped as table columns $ dbFields = DB :: field_list ( $ table ) ; if ( ! $ dbFields ) { return false ; } $ objFields = $ object -> getSchema ( ) -> databaseFields ( $ object , false ) ; $ missingFields = array_diff_key ( $ objFields , $ dbFields ) ; if ( $ missingFields ) { return false ; } return true ; }
Check if the DB is able to safely query this model

@return bool
Check if the DB is able to safely query this model