' Gambas class file

Create Static

Property DBHost As String     ' `DBHost` is a directory - only for SQLite3
'-------------------------------------------------------------------------
Property DBType As String     ' Only for MySQL and PostgreSQL
Property DBUser As String     ' Only for MySQL and PostgreSQL
Property DBPassword As String ' Only for MySQL and PostgreSQL
Property DBPort As String     ' Only for MySQL and PostgreSQL
Property DBName As String
'-------------------------------------------------------------------------
Property Read DBConnection As Connection ' Singleton

Private $DBHost As String
Private $DBType As String
Private $DBUser As String
Private $DBPassword As String
Private $DBPort As String
Private $DBName As String

Private $DBConnection As New Connection


'-- Begin of declaration of property DBConnection -------------------------------------------------

Private Function DBConnection_Read() As Connection

    If Not $DBConnection.Opened Then
       $DBConnection.Type = $DBType  ' The database server type must be in lower case!
       $DBConnection.Host = $DBHost  ' `DBHost` is a directory - only for SQLite3
       $DBConnection.Name = $DBName  ' Name of the SQLite3 database
     ' ------------------------------
     ' $DBConnection.User = Null
     ' $DBConnection.Password = Null
     ' $DBConnection.Port = Null
     ' ------------------------------
       $DBConnection.Open()
    Endif
    
    Return $DBConnection
    
    Catch
      Error.Propagate()

End

'-- End of declaration of property DBConnection ---------------------------------------------------

Private Function DBType_Read() As String
  Return $DBType
End

Private Sub DBType_Write(Value As String)
  $DBType = Value
End

Private Function DBHost_Read() As String
  Return $DBHost
End

Private Sub DBHost_Write(Value As String)
  $DBHost = Value
End

Private Function DBName_Read() As String
  Return $DBName
End

Private Sub DBName_Write(Value As String)
  $DBName = Value
End

'------------------------------------------------

Private Function DBUser_Read() As String
  Return $DBUser
End

Private Sub DBUser_Write(Value As String)
  $DBUser = Value
End

Private Function DBPassword_Read() As String
  Return $DBPassword
End

Private Sub DBPassword_Write(Value As String)
  $DBPassword = Value
End

Private Function DBPort_Read() As String
  Return $DBPort
End

Private Sub DBPort_Write(Value As String)
  $DBPort = Value
End
