function runPatches() { global $patch; global $db_server; global $dbh; $db = new db(); #DEFINE SQL PATCH $display_block = ""; $sql = "SHOW TABLES LIKE '" . TB_PREFIX . "sql_patchmanager'"; if ($db_server == 'pgsql') { $sql = "SELECT 1 FROM pg_tables WHERE tablename ='" . TB_PREFIX . "sql_patchmanager'"; } $sth = $db->query($sql); $rows = $sth->fetchAll(); $display_block .= <<<EOD \t\t<br /> \t\t<b>Simple Invoices :: Database Upgrade Manager</b><br /> \t\t<hr /> \t\t<br />The database patches have now been applied. You can now start working with Simple Invoices.<br /> \t\t<p align=middle><br /><a href="index.php"><font color="green">HOME</font></a></p> <table align='center'> EOD; if (count($rows) == 1) { if ($db_server == 'pgsql') { // Yay! Transactional DDL $dbh->beginTransaction(); } for ($i = 0; $i < count($patch); $i++) { // run_sql_patch($i,$patch[$i]); // use instead of following line if patch application status display is to be suppressed $display_block .= run_sql_patch($i, $patch[$i]); } if ($db_server == 'pgsql') { // Yay! Transactional DDL $dbh->commit(); } $display_block .= "\n</table>"; //exit(); $refresh = '<meta http-equiv="refresh" content="5;url=index.php">'; } else { $display_block .= "\n<tr><td><br /><br />Step 1 - This is the first time Database Updates has been run<br /></td></tr>"; initialise_sql_patch(); $display_block .= "\n<tr><td><br />Now that the Database upgrade table has been initialised, please go back to the Database Upgrade Manger page by clicking <a href='index.php?module=options&view=database_sqlpatches'>HERE</a> to run the remaining patches</td></tr>"; $display_block .= "\n</table>"; } global $smarty; $smarty->assign("display_block", $display_block); $smarty->assign("refresh", $refresh); }
function runPatches() { global $patch; global $db_server; global $dbh; #DEFINE SQL PATCH $display_block = ""; $sql = "SHOW TABLES LIKE '" . TB_PREFIX . "sql_patchmanager'"; if ($db_server == 'pgsql') { $sql = "SELECT 1 FROM pg_tables WHERE tablename ='" . TB_PREFIX . "sql_patchmanager'"; } $sth = dbQuery($sql); $rows = $sth->fetchAll(); $smarty_datas = array(); if (count($rows) >= 1) { if ($db_server == 'pgsql') { // Yay! Transactional DDL $dbh->beginTransaction(); } for ($i = 0; $i < count($patch); $i++) { // run_sql_patch($i,$patch[$i]); // use instead of following line if patch application status display is to be suppressed $smarty_datas['rows'][$i] = run_sql_patch($i, $patch[$i]); } if ($db_server == 'pgsql') { // Yay! Transactional DDL $dbh->commit(); } $smarty_datas['message'] = "The database patches have now been applied. You can now start working with Simple Invoices"; $smarty_datas['html'] = "<div class='si_toolbar si_toolbar_form'><a href='index.php'>HOME</a></div>"; $smarty_datas['refresh'] = 5; } else { $smarty_datas['html'] = "Step 1 - This is the first time Database Updates has been run"; $smarty_datas['html'] = initialise_sql_patch(); $smarty_datas['html'] .= "<br />\n\t\tNow that the Database upgrade table has been initialised, please go back to the Database Upgrade Manger page by clicking \n\t\tthe following button to run the remaining patches.\n\t\t<div class='si_toolbar si_toolbar_form'><a href='index.php?module=options&view=database_sqlpatches'>Continue</a></div>\n\t\t."; } global $smarty; $smarty->assign("page", $smarty_datas); }