ClassModelList::prepareQueryHeaders()This function can be used to simplify the SQL creation for SELECT statement. $headers is a mixed array containing the list columns properties. example : name
namespace
Some other headers params to know, but not used in prepareQueryHeaders() :
NamespacingThis following example shows how to namespace the vars through the headers.
About the standards...A convention is to use '_id' suffix for the foreign keys and primary keys. example :
But this convention cannot handle the case when a table owns 2 fk pointing to the same table. In this case, you will avoid this naming convention making an exception. For example, our namespacing would not work at all. Cook allows you renaming all fields as you want but not the primary key (always id, for the moment). So you cannot adopt this standard for the moment. Note of the conceptor : Personally, I do not like the '_id' suffixes. Maybe it can usefull in some case, but for me never because all FK fields are aliased, and it is only a matter of beiing knowing wich var represent what. Singular, pluralThe namespace parts are composed of the physical field names. Not the sigularizated table alias ! When a cross-reference (Xref) list is instancied in the object, it will use a plural property (highly recommended).
... simple and without conflicts. The N:M tutorial is correctly written in conventions.
Field alias conventions in cookIn order to avoid conflicts, cook has defined its own conventions for building SQL joins. example : country.continent.name Tables aliases are singularizated. It uses the fk field name.
Fields aliases :
In the given example, we have re-aliased '_country_continent_.name' to 'continent'. For loading cross-reference datas (N:M) or reversed foreign key (N:1), you can follow the tutorial. |
|
Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
