Ferreteria/v0.5/table: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
* '''code files''': {{l/ferreteria/code|data/db/table}}
* '''code files''': {{l/ferreteria/code|data/db/table}}


Tables have been [[wooz:2021/12/17/The Great Data-Class Restacking|greatly simplified]] since v0.4, where they (along with Rows and Rowsets) were the basis for specialized classes that constituted what is now called {{l/ver|Feature}}s. There are now just two classes:
Tables have been [[2021/12/17/The Great Data-Class Restacking|greatly simplified]] since v0.4, where they (along with Rows and Rowsets) were the basis for specialized classes that constituted what is now called {{l/ver|Feature}}s. There are now just two classes:
* <code>cTabloid</code>: can use (but does not require) a Feature object; also maintains a static Table registry. Does nothing else.
* <code>cTabloid</code>: can use (but does not require) a Feature object; also maintains a static Table registry. Does nothing else.
* <code>cTable</code>: adds
* <code>cTable</code>: adds
Line 16: Line 16:
Each of these functions return a SelectResult (see {{l/ver|data/space}}).
Each of these functions return a SelectResult (see {{l/ver|data/space}}).


To add a record to a Table, use {{arg|Table object}}<code>->DoInsert(array)</code> - returns <code>cInsertResult</code> (see {{l/ferreteria/code|data/space/ops.php}}.
To add a record to a Table, use {{arg|Table object}}<code>->DoInsert(array)</code> - returns <code>cInsertResult</code> (see {{l/ferreteria/code|data/space/ops.php}}).
==Related==
==Related==
* [[/spec|Table Spec]] classes
* [[/spec|Table Spec]] classes
* The {{l/ver|registry/table|Table Registry}} involves both {{l/ver|Table}}s and {{l/ver|table/spec|Table Specs}}.
* The {{l/ver|registry/table|Table Registry}} involves both {{l/ver|Table}}s and {{l/ver|table/spec|Table Specs}}.

Latest revision as of 21:03, 4 April 2023

About

Tables have been greatly simplified since v0.4, where they (along with Rows and Rowsets) were the basis for specialized classes that constituted what is now called Features. There are now just two classes:

  • cTabloid: can use (but does not require) a Feature object; also maintains a static Table registry. Does nothing else.
  • cTable: adds
    • functions to access the Table's SQL name
    • function to access the database engine object
    • traits for database interaction (see data/db/table/traits.php)

It's uncertain whether this is a good design, or if either or both of these classes are even needed.

Usage

To retrieve data from a Table, use either of:

  • <Table object>->FetchRecord($sqlFilter) - retrieves a single record; throws an error if more than one match found
  • <Table object>->FetchRecord($sqlFilter) - retrieves zero or more records

Each of these functions return a SelectResult (see data/space).

To add a record to a Table, use <Table object>->DoInsert(array) - returns cInsertResult (see data/space/ops.php).

Related