Quick search:


How to add field properties for database columns automatically

Currently this is only supported for MySQL by PntMysqlDao (the default superclass of QueryHandler).

From initPropertyDescriptors, call addDbFieldProps (example). The properties that are added will have the same names as the columns, and type and maxLength will be based on database column definition. MinLength will be set to 0 if the column can hold null values, otherwise it is set to 1. None of rhe properties will be readOnly.

If no parameters are used, all columns will be used in the order they appear in the table, but if a fieldProperty is already defined it is left untouched. If the $includeList  parameter is not null, only the properties whose names are in the list will be added, in the same order as they appear in the list.

For polymorphic persistency it is possible to pass a tableName. This allows you to control from which table the column definitions are used. If this parameter is null or omitted, the tableName that is answered by the objects getTableName method will be used.

The propertyDescriptors that are added are returend in an array, with the propertyNames as keys. This allows you to make more settings on these propertyDescriptors after they have been added.