Overview

Database Class

Available clientside.
Class
DB
The DB class connects and handles communication with the an SQL server using the QDatabase API.

Method overview

Methods

object DB.new(string driver, string host, string database, string user, string password, int port)
Create a new DB connection object.
Create a new database object:
px = DB.new('QPSQL', 'localhost', 'mydb', 'user01', 'verysecret', '5432')
driver
A string containing the QT SQL driver name. QPSQL: postgresql driver.
host
The hostname to connect to.
database
The database to open.
user
The username to use for authentication.
password
The password to use for authentication.
port
The port to connect to.
Returns The newly created communication object.
nil exec(string query)
Execute an SQL query.
query
A string containing the SQL query to execute.
string value(int index)
Get current value from the result of the last query.
index
The column index number to use for the value retrieval.
Returns A string containing the value in the result cell.
boolean next()
Iterate to next row in result set.
Iterate through a result list and print the value in column 0 in each row:
while db:next()
do
  local item = db:value(0)
  print(item)
end
Returns true if another row is availble, false if the end of the list has been reached.