Blog Tags
Blog Archiv
- Oktober, 2010 (1)
- April, 2010 (1)
- Dezember, 2009 (2)
News
Drupal Modulentwicklung - Check Database Version
Um die Version der verwendeten Datenbank im Zusammenhang mit einem Modul zu prüfen kann man in der my_module.install Datei entsprechend handeln. Hier ein Snipped der dies realisiert.
Im Statusbericht wird eine entsprechende Information angezeigt.
Snipped
<?php
// $Id: blogs_list.install, v 1.0 2009/11/25 16:21:17 quiptime Exp $
/**
* Minimum supported version of MySQL, if it is used.
*/
define('BL_MINIMUM_MYSQL', '4.1.1');
/**
* Minimum supported version of PostgreSQL, if it is used.
*/
define('BL_MINIMUM_PGSQL', '8.1.18');
/**
* Implementation of hook_requirements().
*/
function blogs_list_requirements($phase) {
$requirements = array();
$t = get_t();
$requirements = array();
// Test DB version.
global $db_type;
if (function_exists('db_status_report')) {
$db_type = db_status_report($phase);
}
if ($phase == 'runtime') {
$value = $t('Blogs list requirements ok.');
$severity = REQUIREMENT_OK;
// Test MySQL version.
if (array_key_exists('mysql', $db_type) && version_compare(db_version(), BL_MINIMUM_MYSQL) < 0) {
$value = $t('@database version: @version', array('@database' => $db_type['mysql']['title'], '@version' => db_version()));
$description = $t('Your MySQL installation is too old. The module Blogs list requires at least MySQL %version.', array('%version' => BL_MINIMUM_MYSQL));
$severity = REQUIREMENT_ERROR;
}
// Test PGSQL version.
elseif (array_key_exists('pgsql', $db_type) && version_compare(db_version(), BL_MINIMUM_PGSQL) < 0) {
$value = $t('@database version: @version', array('@database' => $db_type['pgsql']['title'], '@version' => db_version()));
$description = $t('Your PostgreSQL installation is too old. The module Blogs list requires at least PGSQL %version.', array('%version' => BL_MINIMUM_PGSQL));
$severity = REQUIREMENT_ERROR;
}
$requirements['blogs_list'] = array(
'title' => $t('Blogs list'),
'value' => $value,
'description' => $description,
'severity' => $severity,
);
}
return $requirements;
}
- Blog von quiptime
- Anmelden um Kommentare zu schreiben
- Druckversion