| Platform | Since |
|---|---|
| Android | 0.1 |
| iPhone | 0.1 |
| iPad | 0.1 |
| Mobile Web | 1.8 |
The ResultSet instance returned by Titanium.Database.DB.execute.
The following code will install a database and execute SQL statements that will create a table, insert data into it, query the table and iterate through the returned ResultSet.
var db = Ti.Database.open('mydb1Installed'); db.execute('CREATE TABLE IF NOT EXISTS people (name TEXT, phone_number TEXT, city TEXT)'); db.execute('DELETE FROM people'); var thisName = 'Arthur'; var thisPhoneNo = '1-617-000-0000'; var thisCity = 'Mountain View'; db.execute('INSERT INTO people (name, phone_number, city) VALUES (?, ?, ?)', thisName, thisPhoneNo, thisCity); var personArray = ['Paul','020 7000 0000', 'London']; db.execute('INSERT INTO people (name, phone_number, city) VALUES (?, ?, ?)', personArray); var rows = db.execute('SELECT rowid,name,phone_number,city FROM people'); db.close(); while (rows.isValidRow()) { Ti.API.info('Person ---> ROWID: ' + rows.fieldByName('rowid') + ', name:' + rows.field(1) + ', phone_number: ' + rows.fieldByName('phone_number') + ', city: ' + rows.field(3)); rows.next(); } rows.close();
Note that the above SELECT query contains the rowid
field, which contains an SQLite-specific unique identifier for each row.
| Name | Summary |
|---|---|
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| close |
Closes this result set and release resources. Once closed, the result set must no longer be used. |
| field |
Retrieves the value for the specified field in the current row, and casts it to the specified type (String, Integer, Float or Double.) |
| fieldByName |
Retrieves the value for the specified field in the current row, and casts it to the specified type (String, Integer, Float or Double.) |
| fieldCount |
Returns the number of columns in this result set. |
| fieldName |
Returns the field name for the specified field index. |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| getRowCount |
Gets the value of the rowCount property. |
| getValidRow |
Gets the value of the validRow property. (iPhone, iPad only.) |
| isValidRow |
Returns whether the current row is valid. |
| next |
Advances to the next row in the result set and returns |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| Name | Type | Summary |
|---|---|---|
| rowCount | Number |
The number of rows in this result set. read-only |
| validRow | Boolean |
Indicates whether the current row is valid. (iPhone, iPad only.) read-only |