OctagonMD Posted February 27, 2019 Share Posted February 27, 2019 I am developing a module to pass transactions to a bank and then save transaction info to a MySQL table. During development I stumbled upon 2 critical problems: My payment module doesn't create a DB Table after installation and yet there are no errors. I can configure it without a problem. This module is absent from payment methods list in FO. (I have all checkboxes enabled in Payment > Options) I am including a link to Pastebin showcasing module.php file. You can ignore createPSign() and checkPSign() functions as they are used for generating a key for bank communication. Link to comment Share on other sites More sharing options...
joseantgv Posted February 28, 2019 Share Posted February 28, 2019 Try this and execute the query manually: private function installSQL() { $sql = array(); $sql[] = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."HIDDEN_transactions` ( `id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, `id_cart` INT(10) UNSIGNED NOT NULL, `id_order` INT(10) UNSIGNED DEFAULT NULL, `ammount` DECIMAL(8,2) NOT NULL, `currency` VARCHAR(3) NOT NULL, `order` VARCHAR(32) NOT NULL, `desc` TEXT, `merch_name` VARCHAR(64) NOT NULL, `merch_url` VARCHAR(64) NOT NULL, `merchant` BIGINT(15) NOT NULL, `terminal` MEDIUMINT(8) UNSIGNED NOT NULL, `email` VARCHAR(64) NOT NULL, `merch_address` VARCHAR(64) NOT NULL, `trtype` TINYINT(2) UNSIGNED NOT NULL, `country` VARCHAR(2) NOT NULL, `merch_gmt` VARCHAR(5) NOT NULL, `timestamp` BIGINT(14) NOT NULL, `nonce` VARCHAR(64) NOT NULL, `p_sign` TEXT, `lang` VARCHAR(2) NOT NULL, `action` ENUM('0','1','2','3') DEFAULT NULL, `rc` VARCHAR(3) DEFAULT NULL, `approval` VARCHAR(6) DEFAULT NULL, `rrn` VARCHAR(12) DEFAULT NULL, `int_ref` VARCHAR(32) DEFAULT NULL, `eci` ENUM('05','06','07') DEFAULT NULL ) ENGINE = "._MYSQL_ENGINE_; var_dump($sql);die; foreach ($sql as $q) { if (!DB::getInstance()->execute($sql)) { return false; } } } Link to comment Share on other sites More sharing options...
OctagonMD Posted February 28, 2019 Author Share Posted February 28, 2019 Quote Try this and execute the query manually: private function installSQL() { $sql = array(); $sql[] = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."HIDDEN_transactions` ( `id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, `id_cart` INT(10) UNSIGNED NOT NULL, `id_order` INT(10) UNSIGNED DEFAULT NULL, `ammount` DECIMAL(8,2) NOT NULL, `currency` VARCHAR(3) NOT NULL, `order` VARCHAR(32) NOT NULL, `desc` TEXT, `merch_name` VARCHAR(64) NOT NULL, `merch_url` VARCHAR(64) NOT NULL, `merchant` BIGINT(15) NOT NULL, `terminal` MEDIUMINT(8) UNSIGNED NOT NULL, `email` VARCHAR(64) NOT NULL, `merch_address` VARCHAR(64) NOT NULL, `trtype` TINYINT(2) UNSIGNED NOT NULL, `country` VARCHAR(2) NOT NULL, `merch_gmt` VARCHAR(5) NOT NULL, `timestamp` BIGINT(14) NOT NULL, `nonce` VARCHAR(64) NOT NULL, `p_sign` TEXT, `lang` VARCHAR(2) NOT NULL, `action` ENUM('0','1','2','3') DEFAULT NULL, `rc` VARCHAR(3) DEFAULT NULL, `approval` VARCHAR(6) DEFAULT NULL, `rrn` VARCHAR(12) DEFAULT NULL, `int_ref` VARCHAR(32) DEFAULT NULL, `eci` ENUM('05','06','07') DEFAULT NULL ) ENGINE = "._MYSQL_ENGINE_; var_dump($sql);die; foreach ($sql as $q) { if (!DB::getInstance()->execute($sql)) { return false; } } } The database itself is not of that much importance. Creating a table manually doesn't solve the problem. As for: var_dump($sql);die; Module is installed without a problem. As if installSQL function is not triggered. To test it I added following line at the start of installSQL function: PrestaShopLogger::addLog('Executing IntsallSQL', 1); No log was created. Link to comment Share on other sites More sharing options...
OctagonMD Posted March 8, 2019 Author Share Posted March 8, 2019 Unfortunately, I did not solve this problem. But I might have found the cause. At the moment of bug, I had nginx with PHP 7.3, so I switched to apache and downgraded to PHP 7.2. After that, I installed a fresh copy of Prestashop 1.7.5.1. 1 Link to comment Share on other sites More sharing options...
ZiedDams Posted November 11, 2021 Share Posted November 11, 2021 !DB::getInstance()->execute($q) NOT !DB::getInstance()->execute($sql) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now