Class Index

Classes


v1.2.1

DBQueryResult

This class encapsulates the results returned from a query performed either by DB#query or DB#queryObjects . The two primary attributes provided on this object as a result of an SQL query are:

Summary
Constructor Attributes Constructor Name and Description
The results of a query returned from DB#query
Field Summary
Field Attributes Field Name and Description
An array of the column names returned by the query.
The full data results of the query either as an array of arrays (rows and columns) or an array of objects indexed by column name.
The number of milliseconds elapsed to iterate through the entire result set to the last row.
The number of milliseconds elapsed to generate a plan to execute the query and get the first row.
Detail
DBQueryResult ()
The results of a query returned from DB#query
See:
DB#query
DB#queryObjects
Field Detail
{string[]} columnNames
An array of the column names returned by the query.

{*[[]] | {}[]} data
The full data results of the query either as an array of arrays (rows and columns) or an array of objects indexed by column name.

When the DB#query method is called, this data field contains a two dimensional array containing the results of the query. Here is an example usage pattern:

	    var res = db.query(sql);
	    for (var row = 0; row < res.data.length; ++row) {
	        for (var col = 0; col < res.columnNames.length; ++col) {
	            var cellVal = res.data[row][col];
	            // use data here
	        }
	    }
	

When the DB#queryObjects method is called, this data field contains an array of objects whose properties are the results of the query named by the column name. All column names are returned in upper case, and if multiple columns share the same name, then only the last column's value is saved. Here is an example usage pattern:

	    var res = db.query("SELECT id, name FROM empl");
	    for (var row = 0; row < res.data.length; ++row) {
	        var rowObj = res.data[row];
	        var id = rowObj['ID'];  // Returns column 'ID'
	        var name = rowObj.NAME;  // Returns column 'NAME'
	    }
	
See:
DB#query
DB#queryObjects

{int} fullTime
The number of milliseconds elapsed to iterate through the entire result set to the last row.

{int} planTime
The number of milliseconds elapsed to generate a plan to execute the query and get the first row.

©2012 Sequel Sphere, LLC.