You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/dbmgmt/forge.rst
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,29 +96,33 @@ mechanism for this.
96
96
Adding Fields
97
97
=============
98
98
99
+
$forge->addField()
100
+
------------------
101
+
99
102
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.
103
107
104
108
.. literalinclude:: forge/006.php
105
109
106
110
Additionally, the following key/values can be used:
107
111
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``.
112
116
- ``auto_increment``/true : generates an auto_increment flag on the
113
117
field. Note that the field type must be a type that supports this,
114
-
such as integer.
118
+
such as ``INTEGER``.
115
119
- ``unique``/true : to generate a unique key for the field definition.
116
120
117
121
.. literalinclude:: forge/007.php
118
122
119
123
After the fields have been defined, they can be added using
120
124
``$forge->addField($fields)`` followed by a call to the
121
-
``createTable()`` method.
125
+
:ref:`createTable()<creating-a-table>` method.
122
126
123
127
Notes on Data Types
124
128
-------------------
@@ -154,11 +158,6 @@ TEXT
154
158
``TEXT`` should not be used on SQLSRV. It is deprecated.
155
159
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>`_.
156
160
157
-
$forge->addField()
158
-
------------------
159
-
160
-
The ``addField()`` method will accept the above array.
161
-
162
161
.. _forge-addfield-default-value-rawsql:
163
162
164
163
Raw Sql Strings as Default Values
@@ -243,6 +242,8 @@ You can specify the desired action for the "on update" and "on delete" propertie
243
242
244
243
.. note:: SQLite3 does not support the naming of foreign keys. CodeIgniter will refer to them by ``prefix_table_column_foreign``.
0 commit comments