Mercurial > hg > fapweb
diff msitegen.inc.php @ 502:d2a38070e18f
Partially refactor database upgrading .. not finished yet, and the
conversion procedure does not convert everything.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Dec 2013 17:52:40 +0200 |
parents | 5f6e74b660df |
children | bf2c50cb9dc9 |
line wrap: on
line diff
--- a/msitegen.inc.php Sat Dec 07 17:51:35 2013 +0200 +++ b/msitegen.inc.php Sat Dec 07 17:52:40 2013 +0200 @@ -736,48 +736,22 @@ } -function stCSQLError($sql) -{ - global $db; - die("Error executing SQL query: ".implode("; ", $db->errorInfo())." in statement \"".$sql."\"\n"); - exit; -} - - -function stCLIConnectSQLDB($dbspec) +function stGetDBMeta($dbh, $name) { - global $db; - try { - $db = new PDO($dbspec); - } - catch (PDOException $e) { - error_log("Could not connect to SQL database '".$dbspec."': ".$e->getMessage()."."); - return FALSE; - } - return TRUE; -} - - -function stGetDBMeta($name) -{ - global $db; - - if (($item = stFetchSQL("SELECT * FROM dbmeta WHERE key=".$db->quote($name))) === FALSE) + if (($item = stDBFetchSQL($dbh, "SELECT * FROM dbmeta WHERE key=".$dbh->quote($name))) === FALSE) return FALSE; return stGetSQLSettingData($item); } -function stSetDBMeta($name, $value) +function stSetDBMeta($dbh, $name, $value) { - global $db; - - if (($item = stFetchSQL("SELECT * FROM dbmeta WHERE key=".$db->quote($name))) === FALSE) + if (($item = stDBFetchSQL($dbh, "SELECT * FROM dbmeta WHERE key=".$dbh->quote($name))) === FALSE) return FALSE; - $sql = "UPDATE dbmeta SET ".stGetSettingSQL($item, $value)." WHERE key=".$db->quote($name); - return stExecSQL($sql); + $sql = "UPDATE dbmeta SET ".stGetSettingSQL($item, $value)." WHERE key=".$dbh->quote($name); + return stDBExecSQL($dbh, $sql); }