Skip to content

Commit a506217

Browse files
committed
docs: improve readability
1 parent fa08bb2 commit a506217

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

user_guide_src/source/dbmgmt/forge.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,33 @@ mechanism for this.
9696
Adding Fields
9797
=============
9898

99+
$forge->addField()
100+
------------------
101+
99102
Fields are normally created via an associative array. Within the array, you must
100-
include a ``type`` key that relates to the datatype of the field. For
101-
example, INT, VARCHAR, TEXT, etc. Many datatypes (for example VARCHAR)
102-
also require a ``constraint`` key.
103+
include a ``type`` key that relates to the datatype of the field.
104+
105+
For example, ``INT``, ``VARCHAR``, ``TEXT``, etc.
106+
Many datatypes (for example ``VARCHAR``) also require a ``constraint`` key.
103107

104108
.. literalinclude:: forge/006.php
105109

106110
Additionally, the following key/values can be used:
107111

108-
- ``unsigned``/true : to generate "UNSIGNED" in the field definition.
109-
- ``default``/value : to generate a default value in the field definition.
110-
- ``null``/true : to generate "null" in the field definition. Without this,
111-
the field will default to "NOT null".
112+
- ``unsigned``/true : to generate ``UNSIGNED`` in the field definition.
113+
- ``default``/value : to generate ``DEFAULT`` constraint in the field definition.
114+
- ``null``/true : to generate ``NULL`` in the field definition. Without this,
115+
the field will default to ``NOT NULL``.
112116
- ``auto_increment``/true : generates an auto_increment flag on the
113117
field. Note that the field type must be a type that supports this,
114-
such as integer.
118+
such as ``INTEGER``.
115119
- ``unique``/true : to generate a unique key for the field definition.
116120

117121
.. literalinclude:: forge/007.php
118122

119123
After the fields have been defined, they can be added using
120124
``$forge->addField($fields)`` followed by a call to the
121-
``createTable()`` method.
125+
:ref:`createTable() <creating-a-table>` method.
122126

123127
Notes on Data Types
124128
-------------------
@@ -154,11 +158,6 @@ TEXT
154158
``TEXT`` should not be used on SQLSRV. It is deprecated.
155159
See `ntext, text, and image (Transact-SQL) - SQL Server | Microsoft Learn <https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-ver16>`_.
156160

157-
$forge->addField()
158-
------------------
159-
160-
The ``addField()`` method will accept the above array.
161-
162161
.. _forge-addfield-default-value-rawsql:
163162

164163
Raw Sql Strings as Default Values
@@ -243,6 +242,8 @@ You can specify the desired action for the "on update" and "on delete" propertie
243242

244243
.. note:: SQLite3 does not support the naming of foreign keys. CodeIgniter will refer to them by ``prefix_table_column_foreign``.
245244

245+
.. _creating-a-table:
246+
246247
Creating a Table
247248
================
248249

user_guide_src/source/dbmgmt/forge/007.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
'default' => 'pending',
2828
],
2929
];
30+
$forge->addField($fields);

0 commit comments

Comments
 (0)