diff --git a/install_minimal/upgrades/airtime-2.1.0/DbUpgrade.php b/install_minimal/upgrades/airtime-2.1.0/DbUpgrade.php index f3b00b8d9..9c08f51e0 100644 --- a/install_minimal/upgrades/airtime-2.1.0/DbUpgrade.php +++ b/install_minimal/upgrades/airtime-2.1.0/DbUpgrade.php @@ -15,7 +15,7 @@ class AirtimeDatabaseUpgrade{ UpgradeCommon::MigrateTablesToVersion(__DIR__, '20120411174904'); $sql = "INSERT INTO cc_pref(\"keystr\", \"valstr\") VALUES('scheduled_play_switch', 'on')"; - UpgradeCommon::nonSelectQueryDb($sql); + UpgradeCommon::queryDb($sql); } /* diff --git a/install_minimal/upgrades/airtime-2.1.0/common/UpgradeCommon.php b/install_minimal/upgrades/airtime-2.1.0/common/UpgradeCommon.php index cc8ee35e0..07e63db99 100644 --- a/install_minimal/upgrades/airtime-2.1.0/common/UpgradeCommon.php +++ b/install_minimal/upgrades/airtime-2.1.0/common/UpgradeCommon.php @@ -1,7 +1,4 @@ getMessage().PHP_EOL; - echo $CC_DBC->getUserInfo().PHP_EOL; + try { + $con = Propel::getConnection(); + } catch (Exception $e) { + echo $e->getMessage().PHP_EOL; echo "Database connection problem.".PHP_EOL; - echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists". - " with corresponding permissions.".PHP_EOL; + echo "Check if database exists with corresponding permissions.".PHP_EOL; if ($p_exitOnError) { exit(1); } - } else { - $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); + return false; } + return true; } public static function DbTableExists($p_name) { - global $CC_DBC; - $sql = "SELECT * FROM ".$p_name; - $result = $CC_DBC->GetOne($sql); - if (PEAR::isError($result)) { + $con = Propel::getConnection(); + try { + $sql = "SELECT * FROM ".$p_name." LIMIT 1"; + $con->query($sql); + } catch (PDOException $e){ return false; } return true; @@ -238,27 +234,16 @@ class UpgradeCommon{ fclose($fp); } - public static function selectQueryDb($p_sql){ - global $CC_DBC; + public static function queryDb($p_sql){ + $con = Propel::getConnection(); - $result = $CC_DBC->getRow($p_sql, $fetchmode=DB_FETCHMODE_ASSOC); - if (PEAR::isError($result)) { - echo "Error executing $sql. Exiting."; + try { + $result = $con->exec($p_sql); + } catch (Exception $e) { + echo "Error executing $p_sql. Exiting."; exit(1); } - - return $result; - } - - public static function nonSelectQueryDb($p_sql){ - global $CC_DBC; - $result = $CC_DBC->query($p_sql); - if (PEAR::isError($result)) { - echo "Error executing $sql. Exiting."; - exit(1); - } - return $result; } }