public static function Execute() { self::SetStatement(); self::ExecuteStatement(); Debug::Set('Sql (' . self::GetRowsAffected() . ' rows): ' . self::$_sql); if (self::$_name) { Data::SetName(self::$_name); Data::Set(self::$_statement->fetchAll(PDO::FETCH_ASSOC)); } self::$_name = null; self::$_sql = null; }
public static function Setup() { Debug::Set('Database setup initiated'); self::SetType('mysql'); self::SetHostname('localhost'); self::SetUsername(getenv('BALLCALC_USERNAME')); self::SetPassword(getenv('BALLCALC_PASSWORD')); self::SetPort('3306'); self::SetDefaultDatabase('steel_bearing'); Debug::Set('Database type: ' . self::GetType()); Debug::Set('Database host: ' . self::GetHostname()); Debug::Set('Database username: ***************'); Debug::Set('Database password: ***************'); Debug::Set('Database port: ' . self::GetPort()); Debug::Set('Database default database: ' . self::GetDefaultDatabase()); try { self::SetConnection(new PDO(self::GetType() . ': host=' . self::GetHostname() . '; port=' . self::GetPort() . '; dbname=' . self::GetDefaultDatabase(), self::GetUsername(), self::GetPassword())); self::SetConnectionStatus('ok'); Debug::Set('Database connection SUCCESS'); } catch (PDOException $e) { self::SetConnectionStatus($e->getMessage()); Debug::Set('Database connection FAILED'); } }