SQL Yoga version 1.1.0 build 4 :: Visit website

Printer friendly version

command tableobj_createObject

Creates a Table Object.

command tableobj_createObject pName, [pType]
Parameters
TypeNameDescription
Simple parameter. pName The name of the Table Object to create.
OptionalSimple parameter. [pType] "table" or "alias". Default is "table".
OptionalSimple parameter. [pDBKey] Database Object table is associated with. Default is name returned by sqlyoga_getDefaultDatabase().
Description

Creating a Table Object allows you to take advantage of a number of SQL Yoga features.
SQL Yoga already knows about the tables and fields in your database and can generate
queries for those tables. But when you define Table Objects you can take advantage of:

- Defining Relationships between tables, allowing SQL Yoga to generate hierachel query results.
- Defining Scopes, or predefined searches, which make dynamic searches a snap.
- Defining additional table properties i.e. a property that returns a condensed version of a field with lots of text.
- Defining callbacks when records are created, deleted, retrieved or updated.

In addition, a Table Object can be an "alias" to another table. An alias is a table object that points to a real table but has certain conditions that filter the content returned. For example, you may have an 'attributes' table for foods. While 'attributes' is a single table you may have a field called 'type' that categorizes the various attributes. If you wanted to treat different types of 'attributes' as their own tables you could creat ean alias to the 'attributes' table. For example, you could create a
an alias called "region". The table would be the 'attributes' table but the 'conditions' would be:

type = "region"
.
Whenever you referenced the 'region' table in a SQL Query Object or join SQL Yoga would know to target the 'attributes' table and to add type="region" to the WHERE condition.

Return

Error message return in 'the result'. Table Object reference array returned in 'it'.