diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 04c9e7841..dc4776ee5 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -19,6 +19,7 @@ require_once __DIR__."/configs/constants.php"; require_once 'Preference.php'; require_once "DateHelper.php"; require_once "OsPath.php"; +require_once "Database.php"; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; diff --git a/airtime_mvc/application/common/Database.php b/airtime_mvc/application/common/Database.php new file mode 100644 index 000000000..96e6e6770 --- /dev/null +++ b/airtime_mvc/application/common/Database.php @@ -0,0 +1,24 @@ +prepare($sql); + foreach ($paramValueMap as $param => $v) { + $stmt->bindValue($param, $v); + } + $rows = array(); + if ($stmt->execute()) { + if ($type == 'single') { + $rows = $stmt->fetch(PDO::FETCH_ASSOC); + } else if ($type == 'column'){ + $rows = $stmt->fetchColumn(); + } else { + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + } else { + $msg = implode(',', $stmt->errorInfo()); + throw new Exception("Error: $msg"); + } + return $rows; + } +} \ No newline at end of file