v5:dictionary:comments
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| v5:dictionary:comments [2026/03/22 17:28] – created mnewnham | v5:dictionary:comments [2026/03/22 23:45] (current) – mnewnham | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Adding Comments To Tables ===== | ===== Adding Comments To Tables ===== | ||
| - | Database support for adding comments varies from full support (IBM DB2, PostgreSQL) to none (SQLite) with differing implementation methods. Databases that support it do it via 1 of 2 methods, Either be adding the comment as part of the table creation and modification process, or by adding a comment to a previously created table. | + | Database support for adding comments varies from full support (IBM DB2, PostgreSQL) to none (SQLite) with differing implementation methods. Databases that support it do it via 1 of 2 methods, Either be adding the comment as part of the table creation and modification process, or by adding a comment to a previously created table. |
| + | |||
| + | ^ ^ db2 ^ mssqlnative | ||
| + | ^ Table On Creation | ||
| + | ^ Column On Creation | ||
| + | ^ Index On Creation | ||
| + | ^ Table After Creation | ||
| + | ^ Column After Creation | ||
| + | ^ Index After Creation | ||
| + | |||
| + | ==== Creating Comments During Table Creation ==== | ||
| + | Creation during data dictionary functions such as createTableSql(), | ||
| + | === Table === | ||
| + | <code php> | ||
| + | $datadict = newDataDictionary($db); | ||
| + | |||
| + | $flds = 'an ADOdb fields definition...'; | ||
| + | $tableOpts = [' | ||
| + | |||
| + | $sqlarray = $datadict-> | ||
| + | |||
| + | $datadict-> | ||
| + | </ | ||
| + | |||
| + | ==== Column ==== | ||
| + | <code php> | ||
| + | $datadict = newDataDictionary($db); | ||
| + | |||
| + | $flds = " | ||
| + | |||
| + | $sqlarray = $datadit-> | ||
| + | |||
| + | $datadict-> | ||
| + | </ | ||
| + | === Index === | ||
| + | <code php> | ||
| + | $datadict = newDataDictionary($db); | ||
| + | |||
| + | $flds = " | ||
| + | $indexOptions = array( | ||
| + | ' | ||
| + | ' | ||
| + | ); | ||
| + | |||
| + | $sqlarray = $datadict-> | ||
| + | |||
| + | $datadict-> | ||
| + | </ | ||
| + | |||
| + | ==== Creating Comments Using XMLSchema ==== | ||
| + | * Comments can now be added to table, column and index elements and are added if possible to the database schema. | ||
| + | * This is done by adding **< | ||
| + | * The **< | ||
| + | |||
| + | <code xml> | ||
| + | <table name=" | ||
| + | < | ||
| + | < | ||
| + | <field name=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | <index name=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== Modifying Comments ==== | ||
| + | Databases that support creating comments via dictionary table functions have limited ability to modify comments after creation. Only columns comments can be modified, and this requires the entire column specification to be provided. | ||
| + | |||
| + | ===== Creating Comments After Table Creation ===== | ||
| + | For databases that provide the ability to create comments after table creation, the following methods are provided | ||
| + | ==== Table ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string setTableCommentSql( | ||
| + | string $tableName, | ||
| + | ?string $comment | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | --------------------------------------- | ||
| + | |||
| + | <code php> | ||
| + | /* | ||
| + | * Assume connection to IBM DB2 database | ||
| + | */ | ||
| + | |||
| + | $table = ' | ||
| + | $comment = 'This is a table comment'; | ||
| + | |||
| + | $datadict = newDataDictionary($db); | ||
| + | $tableCommentSql = $datadict-> | ||
| + | |||
| + | /* | ||
| + | * Returns | ||
| + | */ | ||
| + | |||
| + | $db-> | ||
| + | </ | ||
| + | |||
| + | ==== Column ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string setColumnCommentSql( | ||
| + | string $tableName, | ||
| + | string $columnName, | ||
| + | ?string $comment | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | --------------------------------------- | ||
| + | |||
| + | ==== Index ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string setIndexCommentSql( | ||
| + | string $tableName, | ||
| + | string $indexName, | ||
| + | ?string $comment | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | --------------------------------------- | ||
| + | ===== Reading Comments ===== | ||
| + | All databases use the same methods to retrieve comments set in the database. | ||
| + | ==== Table ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string getTableCommentSql( | ||
| + | string $tableName | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | --------------------------------------- | ||
| + | <code php> | ||
| + | /* | ||
| + | * Assume connection to a PostgresQL database | ||
| + | */ | ||
| + | |||
| + | $table = ' | ||
| + | |||
| + | |||
| + | $datadict = newDataDictionary($db); | ||
| + | $tableCommentSql = $datadict-> | ||
| + | |||
| + | /* | ||
| + | * Returns | ||
| + | */ | ||
| + | |||
| + | $comment = $db-> | ||
| + | </ | ||
| + | ==== Column ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string getColumnCommentSql( | ||
| + | string $tableName, | ||
| + | string $columnName | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | --------------------------------------- | ||
| + | |||
| + | ==== Index ==== | ||
| + | <WRAP right box> | ||
| + | == Syntax == | ||
| + | |||
| + | ?string getIndexCommentSql( | ||
| + | string $tableName, | ||
| + | string $indexName | ||
| + | ) | ||
| + | |||
| + | </ | ||
| + | **ADODataDictionary:: | ||
| + | |||
| + | ---------------------------------- | ||
| + | |||
| + | ===== Deprecated Functions ===== | ||
| + | The functions **getCommentSql()** and **setCommentSql()** which get/set table comments in the oci8 driver are deprecated and will be removed in a later release. They currently alias **getTableCommentSql()** and **setTableCommentSql()** | ||
v5/dictionary/comments.1774196893.txt.gz · Last modified: by mnewnham
