Use default database connection

This commit is contained in:
Dennis Eichhorn 2017-09-23 13:58:09 +02:00
parent de9290e273
commit b423d9ef87

View File

@ -38,10 +38,10 @@ class Installer extends InstallerAbstract
{ {
parent::install(__DIR__ . '/..', $dbPool, $info); parent::install(__DIR__ . '/..', $dbPool, $info);
switch ($dbPool->get('core')->getType()) { switch ($dbPool->get()->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_category` ( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'qa_category` (
`qa_category_id` int(11) NOT NULL AUTO_INCREMENT, `qa_category_id` int(11) NOT NULL AUTO_INCREMENT,
`qa_category_name` varchar(255) NOT NULL, `qa_category_name` varchar(255) NOT NULL,
`qa_category_parent` int(11) DEFAULT NULL, `qa_category_parent` int(11) DEFAULT NULL,
@ -50,21 +50,21 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'qa_category` 'ALTER TABLE `' . $dbPool->get()->prefix . 'qa_category`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_category_ibfk_1` FOREIGN KEY (`qa_category_parent`) REFERENCES `' . $dbPool->get('core')->prefix . 'qa_category` (`qa_category_id`)' ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_category_ibfk_1` FOREIGN KEY (`qa_category_parent`) REFERENCES `' . $dbPool->get()->prefix . 'qa_category` (`qa_category_id`)'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_badge` ( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'qa_badge` (
`qa_badge_id` int(11) NOT NULL AUTO_INCREMENT, `qa_badge_id` int(11) NOT NULL AUTO_INCREMENT,
`qa_badge_name` varchar(255) NOT NULL, `qa_badge_name` varchar(255) NOT NULL,
PRIMARY KEY (`qa_badge_id`) PRIMARY KEY (`qa_badge_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_question` ( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'qa_question` (
`qa_question_id` int(11) NOT NULL AUTO_INCREMENT, `qa_question_id` int(11) NOT NULL AUTO_INCREMENT,
`qa_question_status` int(11) NOT NULL, `qa_question_status` int(11) NOT NULL,
`qa_question_title` varchar(255) NOT NULL, `qa_question_title` varchar(255) NOT NULL,
@ -79,14 +79,14 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'qa_question` 'ALTER TABLE `' . $dbPool->get()->prefix . 'qa_question`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_question_ibfk_1` FOREIGN KEY (`qa_question_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_question_ibfk_1` FOREIGN KEY (`qa_question_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`),
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_question_ibfk_2` FOREIGN KEY (`qa_question_category`) REFERENCES `' . $dbPool->get('core')->prefix . 'qa_category` (`qa_category_id`);' ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_question_ibfk_2` FOREIGN KEY (`qa_question_category`) REFERENCES `' . $dbPool->get()->prefix . 'qa_category` (`qa_category_id`);'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_question_badge` ( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'qa_question_badge` (
`qa_question_badge_id` int(11) NOT NULL AUTO_INCREMENT, `qa_question_badge_id` int(11) NOT NULL AUTO_INCREMENT,
`qa_question_badge_question` int(11) NOT NULL, `qa_question_badge_question` int(11) NOT NULL,
`qa_question_badge_badge` int(11) DEFAULT NULL, `qa_question_badge_badge` int(11) DEFAULT NULL,
@ -96,14 +96,14 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'qa_question_badge` 'ALTER TABLE `' . $dbPool->get()->prefix . 'qa_question_badge`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_question_badge_ibfk_1` FOREIGN KEY (`qa_question_badge_question`) REFERENCES `' . $dbPool->get('core')->prefix . 'qa_question` (`qa_question_id`), ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_question_badge_ibfk_1` FOREIGN KEY (`qa_question_badge_question`) REFERENCES `' . $dbPool->get()->prefix . 'qa_question` (`qa_question_id`),
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_question_badge_ibfk_2` FOREIGN KEY (`qa_question_badge_badge`) REFERENCES `' . $dbPool->get('core')->prefix . 'qa_badge` (`qa_badge_id`)' ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_question_badge_ibfk_2` FOREIGN KEY (`qa_question_badge_badge`) REFERENCES `' . $dbPool->get()->prefix . 'qa_badge` (`qa_badge_id`)'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_answer` ( 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'qa_answer` (
`qa_answer_id` int(11) NOT NULL AUTO_INCREMENT, `qa_answer_id` int(11) NOT NULL AUTO_INCREMENT,
`qa_answer_status` int(11) NOT NULL, `qa_answer_status` int(11) NOT NULL,
`qa_answer_accepted` tinyint(1) NOT NULL, `qa_answer_accepted` tinyint(1) NOT NULL,
@ -117,10 +117,10 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute(); )->execute();
$dbPool->get('core')->con->prepare( $dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'qa_answer` 'ALTER TABLE `' . $dbPool->get()->prefix . 'qa_answer`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_answer_ibfk_1` FOREIGN KEY (`qa_answer_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`), ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_answer_ibfk_1` FOREIGN KEY (`qa_answer_created_by`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`),
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'qa_answer_ibfk_2` FOREIGN KEY (`qa_answer_question`) REFERENCES `' . $dbPool->get('core')->prefix . 'qa_question` (`qa_question_id`);' ADD CONSTRAINT `' . $dbPool->get()->prefix . 'qa_answer_ibfk_2` FOREIGN KEY (`qa_answer_question`) REFERENCES `' . $dbPool->get()->prefix . 'qa_question` (`qa_question_id`);'
)->execute(); )->execute();
break; break;
} }