MYSQL.class_from_table (symclassname, superclass, tablename)
A symbol, representing the name of the class to create.
The superclass for the newly created class, or nil.
The name of the MySQL table, as a string, to use as the template for this class.
This method of the MYSQL class creates a new Gamma class whose instance variables correspond to the column names in the table tablename. If the class named symclassname already exists, or the table tablename does not exist in the MySQL database, then this function returns nil.
This method is defined in the Gamma library /usr/cogent/require/MySQLSupport.g. It is made available to a Gamma program with the statement: require("MySQLSupport");.
This example is taken from Section 2.2, “Tutorial 2: create_pets.g”
... /* Test the MYSQL.class_from_table method. */ mysql.class_from_table (#mypetclass, nil, "pets"); pretty_princ ("\nCLASS The .class_from_table method ", "returns the mypetclass:\n", mypetclass, "\n"); ...
The output for this section of the code is as follows:
CLASS The .class_from_table method returns the mypetclass: (defclass mypetclass nil [(__columns . #0=[id name owner species sex birth death]) (__primary_key . id) (__table . #1=pets)] [birth death id name owner sex species])
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.