function update041() { $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED); //Add Table $sqlfileInfo = $this->_mTargetXoopsModule->getInfo('sqlfile'); $dirname = $this->_mTargetXoopsModule->getVar('dirname'); $sqlfile = $sqlfileInfo[XOOPS_DB_TYPE]; $sqlfilepath = XOOPS_MODULE_PATH . '/' . $dirname . '/' . $sqlfile; require_once XOOPS_MODULE_PATH . '/legacy/admin/class/Legacy_SQLScanner.class.php'; $scanner = new Legacy_SQLScanner(); $scanner->setDB_PREFIX(XOOPS_DB_PREFIX); $scanner->setDirname($this->_mTargetXoopsModule->get('dirname')); if (!$scanner->loadFile($sqlfilepath)) { $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_SQL_FILE_NOT_FOUND, $sqlfile)); return false; } $scanner->parse(); $sqls = $scanner->getSQL(); $root = XCube_Root::getSingleton(); $db = $root->mController->getDB(); foreach ($sqls as $sql) { if (strpos($sql, '_message_users') !== false) { if (!$db->query($sql)) { $this->mLog->addError($db->error()); return false; } } } $this->mLog->addReport(_AD_LEGACY_MESSAGE_DATABASE_SETUP_FINISHED); //add table $this->updatemain(); return true; }
/** * DBquery * * @param string $query * @param XoopsModule &$module * @param Legacy_ModuleInstallLog &$log * * @return bool **/ public static function DBquery($query, &$module, &$log) { require_once XOOPS_MODULE_PATH . '/legacy/admin/class/Legacy_SQLScanner.class.php'; // TODO will be use other class? $scanner = new Legacy_SQLScanner(); $scanner->setDB_PREFIX(XOOPS_DB_PREFIX); $scanner->setDirname($module->get('dirname')); $scanner->setBuffer($query); $scanner->parse(); $sqls = $scanner->getSQL(); $root =& XCube_Root::getSingleton(); $successFlag = true; foreach ($sqls as $sql) { if ($root->mController->mDB->query($sql)) { $log->addReport(XCube_Utils::formatString(_MI_LEIMG_INSTALL_MSG_SQL_SUCCESS, $sql)); } else { $log->addReport(XCube_Utils::formatString(_MI_LEIMG_INSTALL_MSG_SQL_ERROR, $sql)); $successFlag = false; } } return $successFlag; }
/** * DB query. * * @param string $query * @param XoopsModule &$module * @param Legacy_ModuleInstallLog &$log * * @return bool */ public static function DBquery($query, &$module, &$log) { $dirname = $module->get('dirname'); $constpref = '_MI_' . strtoupper($dirname); require_once XOOPS_MODULE_PATH . '/legacy/admin/class/Legacy_SQLScanner.class.php'; $scanner = new Legacy_SQLScanner(); $scanner->setDB_PREFIX(XOOPS_DB_PREFIX); $scanner->setDirname($dirname); $scanner->setBuffer($query); $scanner->parse(); $sqls = $scanner->getSQL(); $root =& XCube_Root::getSingleton(); $successFlag = true; foreach ($sqls as $sql) { if ($root->mController->mDB->query($sql)) { $log->addReport(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_SQL_SUCCESS'), $sql)); } else { $log->addReport(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_SQL_ERROR'), $sql)); $successFlag = false; } } return $successFlag; }
/** * Executes SQL query as cube style. */ function DBquery($query, &$module, $log) { require_once XOOPS_MODULE_PATH . "/legacy/admin/class/Legacy_SQLScanner.class.php"; $successFlag = true; $scanner = new Legacy_SQLScanner(); $scanner->setDB_PREFIX(XOOPS_DB_PREFIX); $scanner->setDirname($module->get('dirname')); $scanner->setBuffer($query); $scanner->parse(); $sqlArr = $scanner->getSQL(); $root =& XCube_Root::getSingleton(); foreach ($sqlArr as $sql) { if ($root->mController->mDB->query($sql)) { $log->addReport("Success: {$sql}"); $successFlag &= true; } else { $log->addError("Failure: {$sql}"); $successFlag = false; } } return $successFlag; }