MYSQL_RES.Data()
This method for the MYSQL_RES class replaces the field MYSQL_RES.data that would exist in the C API. Gamma needs to construct a two-dimensional array of data where the array is:
data[row][field_value]
That is, the first dimension of the array is the set of rows, and the second dimension of the array is the field values for each row.
![]() | This is a built-in Gamma method that is similar to but does not exactly does not match the MySQL method MYSQL_RES.Data. |
This example is taken from Section 2.2, “Tutorial 2: create_pets.g”
...
/* Test the MYSQL.query_and_store method. */
query = mysql.query_and_store ("select name, birth from pets");
pretty_princ("\nQUERY The .query_and_store method applied ",
"to the 'name' and 'birth' fields in mypetclass ",
"\nreturns this MYSQL_RES istance:\n", query, "\n");
query_data = query.Data();
pretty_princ("Its data, recovered using ",
"the .Data() method, is:\n", query_data, "\n");
...The output for this section of the code is as follows:
QUERY The .query_and_store method applied to the 'name' and 'birth' fields in mypetclass
returns this MYSQL_RES istance:
{MYSQL_RES (current_field . 0) (eof . 1) (field_count . 2)
(fields . [{MYSQL_FIELD (decimals . 0) (def) (flags . 1)
(length . 20) (max_length . 8) (name . name)
(table . pets) (type . 253)}
{MYSQL_FIELD (decimals . 0) (def) (flags . 0) (length . 10)
(max_length . 10) (name . birth) (table . pets) (type . 10)}])}
Its data, recovered using the .Data() method, is:
[[Claws 1994-03-17] [Buffy 1989-05-13] [Fang 1990-08-27]
[Bowser 1995-08-31] [Chirpy 1998-09-11] [Whistler 1997-12-09]
[Slim 1996-04-29] [Petunia 1925-12-25]]Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.