00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Install_Model_Installer_Db extends Mage_Install_Model_Installer_Abstract
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 public function checkDatabase($data)
00049 {
00050 $config = array(
00051 'host' => $data['db_host'],
00052 'username' => $data['db_user'],
00053 'password' => $data['db_pass'],
00054 'dbname' => $data['db_name']
00055 );
00056
00057 try {
00058 $connection = Mage::getSingleton('core/resource')->createConnection('install', $this->_getConnenctionType(), $config);
00059 $variables = $connection->fetchPairs("SHOW VARIABLES");
00060
00061 $version = isset($variables['version']) ? $variables['version'] : 'undefined';
00062 $match = array();
00063 if (preg_match("#^([0-9\.]+)#", $version, $match)) {
00064 $version = $match[0];
00065 }
00066 $requiredVersion = (string)Mage::getSingleton('install/config')->getNode('check/mysql/version');
00067
00068
00069 if (version_compare($version, $requiredVersion) == -1) {
00070 Mage::throwException(Mage::helper('install')->__('Database server version does not match system requirements (required: %s, actual: %s)', $requiredVersion, $version));
00071 }
00072
00073
00074 if (!isset($variables['have_innodb']) || $variables['have_innodb'] != 'YES') {
00075 Mage::throwException(Mage::helper('install')->__('Database server does not support InnoDB storage engine'));
00076 }
00077 }
00078 catch (Exception $e){
00079 $this->_getInstaller()->getDataModel()->addError($e->getMessage());
00080 Mage::throwException(Mage::helper('install')->__('Database connection error'));
00081 }
00082 }
00083
00084
00085
00086
00087
00088
00089 protected function _getConnenctionType()
00090 {
00091 return (string) Mage::getConfig()->getNode('global/resources/default_setup/connection/type');
00092 }
00093 }