commit version 22.12.12447
This commit is contained in:
30
includes/weathermap/lib/database.php
Normal file
30
includes/weathermap/lib/database.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @return null|PDO
|
||||
*/
|
||||
function weathermap_get_pdo()
|
||||
{
|
||||
// This is the Cacti standard settings
|
||||
global $database_type, $database_default, $database_hostname, $database_username, $database_password;
|
||||
global $config;
|
||||
|
||||
$cacti_version = $config["cacti_version"];
|
||||
|
||||
$host = $database_hostname;
|
||||
$dbname = $database_default;
|
||||
$user = $database_username;
|
||||
$pass = $database_password;
|
||||
|
||||
$pdo = null;
|
||||
|
||||
try {
|
||||
# MySQL with PDO_MYSQL
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
Reference in New Issue
Block a user