Use default database connection

This commit is contained in:
Dennis Eichhorn 2017-09-23 13:58:09 +02:00
parent 70144fc214
commit 216fe6514b
2 changed files with 38 additions and 38 deletions

View File

@ -38,10 +38,10 @@ class Installer extends InstallerAbstract
{
parent::install(__DIR__ . '/..', $dbPool, $info);
switch ($dbPool->get('core')->getType()) {
switch ($dbPool->get()->getType()) {
case DatabaseType::MYSQL:
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_account` (
`profile_account_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_account_image` int(11) DEFAULT NULL,
`profile_account_birthday` datetime DEFAULT NULL,
@ -52,15 +52,15 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_account`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_account_ibfk_1` FOREIGN KEY (`profile_account_image`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`),
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_account_ibfk_2` FOREIGN KEY (`profile_account_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_account`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_account_ibfk_1` FOREIGN KEY (`profile_account_image`) REFERENCES `' . $dbPool->get()->prefix . 'media` (`media_id`),
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_account_ibfk_2` FOREIGN KEY (`profile_account_account`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);'
)->execute();
// real contacts that you also save in your email contact list. this is to store other accounts
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_contact` (
`profile_contact_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_contact_name1` varchar(250) NOT NULL,
`profile_contact_name2` varchar(250) NOT NULL,
@ -77,14 +77,14 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_contact`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_ibfk_1` FOREIGN KEY (`profile_contact_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_contact`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_contact_ibfk_1` FOREIGN KEY (`profile_contact_account`) REFERENCES `' . $dbPool->get()->prefix . 'profile_account` (`profile_account_id`);'
)->execute();
// email, phone etc for profile_contact
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contact_element` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_contact_element` (
`profile_contact_element_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_contact_element_type` tinyint(2) NOT NULL,
`profile_contact_element_subtype` tinyint(2) NOT NULL,
@ -95,14 +95,14 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_contact_element`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contact_element_ibfk_1` FOREIGN KEY (`profile_contact_element_contact`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_contact` (`profile_contact_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_contact_element`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_contact_element_ibfk_1` FOREIGN KEY (`profile_contact_element_contact`) REFERENCES `' . $dbPool->get()->prefix . 'profile_contact` (`profile_contact_id`);'
)->execute();
// not a full contact only the element like email, phone etc. for the accounts themselves (not profile_account)
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_contactelement` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_contactelement` (
`profile_contactelement_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_contactelement_type` tinyint(2) NOT NULL,
`profile_contactelement_subtype` tinyint(2) NOT NULL,
@ -113,13 +113,13 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_contactelement`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_contactelement_ibfk_1` FOREIGN KEY (`profile_contactelement_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_contactelement`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_contactelement_ibfk_1` FOREIGN KEY (`profile_contactelement_account`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);'
)->execute();
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_address` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_address` (
`profile_address_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_address_type` tinyint(2) NOT NULL,
`profile_address_address` varchar(255) NOT NULL,
@ -133,13 +133,13 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_address`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_address_ibfk_1` FOREIGN KEY (`profile_address_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_address`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_address_ibfk_1` FOREIGN KEY (`profile_address_account`) REFERENCES `' . $dbPool->get()->prefix . 'profile_account` (`profile_account_id`);'
)->execute();
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_relation` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_account_relation` (
`profile_account_relation_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_account_relation_type` tinyint(2) NOT NULL,
`profile_account_relation_relation` int(11) DEFAULT NULL,
@ -149,13 +149,13 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_account_relation`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_account_relation_ibfk_1` FOREIGN KEY (`profile_account_relation_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_account_relation`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_account_relation_ibfk_1` FOREIGN KEY (`profile_account_relation_account`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);'
)->execute();
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'profile_account_setting` (
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'profile_account_setting` (
`profile_account_setting_id` int(11) NOT NULL AUTO_INCREMENT,
`profile_account_setting_module` int(11) NOT NULL,
`profile_account_setting_type` varchar(20) NOT NULL,
@ -166,9 +166,9 @@ class Installer extends InstallerAbstract
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'profile_account_setting`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'profile_account_setting_ibfk_1` FOREIGN KEY (`profile_account_setting_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'profile_account_setting`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'profile_account_setting_ibfk_1` FOREIGN KEY (`profile_account_setting_account`) REFERENCES `' . $dbPool->get()->prefix . 'account` (`account_id`);'
)->execute();
break;
}

View File

@ -39,7 +39,7 @@ class Uninstall extends UninstallAbstract
$query = new Builder($dbPool->get());
$query->prefix($dbPool->get('core')->getPrefix())->drop(
$query->prefix($dbPool->get()->getPrefix())->drop(
'profile_account_setting',
'profile_account_relation',
'profile_address',