Plugin:MirLua/Module/m database/de

From Miranda NG
Revision as of 01:47, 4 November 2024 by Wishmaster (talk | contribs) (Created page with "== Einstellungen ==")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Allows you to access data and contacts in user profile database.

Inkludieren Sie folgendes Modul: local db = require('m_database')

Kontakte

Contacts

Iterator for list of contacts.

Parameter

Parametername Benötigt Typ Beschreibung
name Ja string Protocol name.

Ergebnis

     Typ: number

     Returns contact number. The list ends in element with nil value.

Beispiel

for hContact in db.Contacts('JABBER_1') do
  print(db.GetSetting(hContact, 'JABBER_1', 'Nick'))
end

Ereignisse

GetEventCount

Number of events for a contact.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number.

Ergebnis

     Typ: number

     Returns number of events.

Beispiel

db.GetEventCount(hContact)

Events

Iterator for contact's event list from the first to the last.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number.

Ergebnis

     Typ: number

     Returns event number. The list ends in element with nil value.

Beispiel

for hEvent in db.Events(hContact) do
  local event = totable(hEvent, "DBEVENTINFO")
  print(event.Timestamp, event.Blob)
end

EventsFromEnd

Iterator for contact's event list from the last to the first.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number.

Ergebnis

     Typ: number

     Returns event number. The list ends in element with nil value.

Beispiel

for hEvent in db.EventsFromEnd(hContact) do
  local event = totable(hEvent, "DBEVENTINFO")
  print(event.Timestamp, event.Blob)
end

Einstellungen

GetSetting

Returns value of a setting.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number or nil.
module Ja string Module name.
setting Ja string Setting name.
value Nein number, string Default value.

Ergebnis

     Typ: number

     Returns value of a setting or default value or nil.

Beispiel

db.GetSetting(nil, 'test', 'some')

Settings

Iterator for module (group of settings).

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number or nil.
module Ja string Module name.

Ergebnis

     Typ: number

     Returns module name. The list ends in element with nil value.

Beispiel

for setting in db.Settings(nil, 'CList') do
  local message = string.format("%s/%s = ", 'CList', setting, ...)
   .. db.GetSetting(nil, 'CList', setting)
  print(message)
end

WriteSetting

Saves a value to database.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number or nil.
module Ja string Module name.
setting Ja string Setting name.
value Ja boolean, number, string, table (array of bytes) Setting value.
type Nein number Type of setting. Takes values:
  • 1 = DBVT_BYTE
  • 2 = DBVT_WORD
  • 4 = DBVT_DWORD
  • 252 = DBVT_WCHAR
  • 253 = DBVT_UTF8
  • 254 = DBVT_BLOB
  • 255 = DBVT_ASCIIZ

Ergebnis

     Typ: boolean

     Returns true on success, otherwise false.

Beispiel

db.WriteSetting(nil, 'test', 'some', true)

DeleteSetting

Deletes a setting.

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number or nil.
module Ja string Module name.
setting Ja string Setting name.

Ergebnis

     Typ: boolean

     Returns true on success, otherwise false.

Beispiel

db.DeleteSetting(nil, 'test', 'some')

DeleteModule

Deletes a module (group of settings).

Parameter

Parametername Benötigt Typ Beschreibung
hContact Ja number Contact number or nil.
module Ja string Module name.

Ergebnis

     Typ: boolean

     Returns true on success, otherwise false.

Beispiel

db.DeleteModule(nil, 'test')