Module dado.object

Database Object.

Offers a way to create objects that are associated to database tables. There are some special attributes: db_fields = table (record) that indicates which attributes should be loaded from the database table_name = string with the name of the database table key_name = string with the name of the key attribute/field

Info:

  • Release: $Id: object.lua,v 1.24 2017/04/05 19:14:08 tomas Exp $

Functions

new (class, dado, o) Creates a new object.
rawdata () Creates a table with the raw data of the object.
insert () Inserts a new record in the database.
update () Updates the data of the object in the corresponding database record.
save () Saves the object data.
class (c) Creates a new class.


Functions

new (class, dado, o)
Creates a new object.

Parameters:

  • class Table representing the class of the object.
  • dado Dado connection.
  • o Table representing the object (optional).

Returns:

    Table representing the object.
rawdata ()
Creates a table with the raw data of the object.

Returns:

    Table with field=value pairs.
insert ()
Inserts a new record in the database.

Returns:

    Boolean indicating the success of the operation.
update ()
Updates the data of the object in the corresponding database record.

Returns:

    Boolean indicating the success of the operation.
save ()
Saves the object data. This function decides when to perform an update or an insert according to the value of the loaded attribute which indicates if the data was already loaded from the database.
class (c)
Creates a new class.

Parameters:

  • c Table with the mandatory fields.

Returns:

    Table representing the class.
generated by LDoc 1.4.6 Last updated 2017-04-05 16:14:10