/** * This class stores a database result. **/ Db.Result = new Class ({ /** * Initilizes the result object. **/ initialize: function (data, columns) { this.data = data; this.columns = columns; this.columnMap = null; this.row = -1; if (columns) { this.columnMap = {}; for (var i = 0; i < columns.length; i++) this.columnMap[columns[i].name] = i; } } /** * Gets a value from de result. * * @param {String} columnName The column name * @return {Object} The cell value **/ ,get: function (columnName) { var columnIndex = this.columnMap[columnName]; return this.data[this.row][columnIndex]; } /** * Resets the result iterator. **/ ,reset: function () { this.row = -1; } /** * Moves the internal iterator to the next row. **/ ,next: function () { this.row++; if (this.row >= this.data.length) return false; return true; } });