Skip to content

Commit f3a34f7

Browse files
committed
docs: change **foo** to headings
You can link to headings, but cannot link to `**foo**`.
1 parent 4ad1edf commit f3a34f7

File tree

1 file changed

+67
-34
lines changed

1 file changed

+67
-34
lines changed

user_guide_src/source/models/model.rst

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ what table to use and how we can find the required records:
8080

8181
.. literalinclude:: model/005.php
8282

83-
**$table**
83+
$table
84+
------
8485

8586
Specifies the database table that this model primarily works with. This only applies to the
8687
built-in CRUD methods. You are not restricted to using only this table in your own
8788
queries.
8889

89-
**$primaryKey**
90+
$primaryKey
91+
-----------
9092

9193
This is the name of the column that uniquely identifies the records in this table. This
9294
does not necessarily have to match the primary key that is specified in the database, but
@@ -95,7 +97,8 @@ is used with methods like ``find()`` to know what column to match the specified
9597
.. note:: All Models must have a primaryKey specified to allow all of the features to work
9698
as expected.
9799

98-
**$useAutoIncrement**
100+
$useAutoIncrement
101+
-----------------
99102

100103
Specifies if the table uses an auto-increment feature for ``$primaryKey``. If set to ``false``
101104
then you are responsible for providing primary key value for every record in the table. This
@@ -106,15 +109,17 @@ default value is ``true``.
106109
key in the database to ``unique``. This way you will make sure that all of Model's features
107110
will still work the same as before.
108111

109-
**$returnType**
112+
$returnType
113+
-----------
110114

111115
The Model's CRUD methods will take a step of work away from you and automatically return
112116
the resulting data, instead of the Result object. This setting allows you to define
113117
the type of data that is returned. Valid values are '**array**' (the default), '**object**', or the **fully
114118
qualified name of a class** that can be used with the Result object's ``getCustomResultObject()``
115119
method.
116120

117-
**$useSoftDeletes**
121+
$useSoftDeletes
122+
---------------
118123

119124
If true, then any ``delete()`` method calls will set ``deleted_at`` in the database, instead of
120125
actually deleting the row. This can preserve data when it might be referenced elsewhere, or
@@ -126,66 +131,81 @@ This requires either a DATETIME or INTEGER field in the database as per the mode
126131
``$dateFormat`` setting. The default field name is ``deleted_at`` however this name can be
127132
configured to any name of your choice by using ``$deletedField`` property.
128133

129-
**$allowedFields**
134+
$allowedFields
135+
--------------
130136

131137
This array should be updated with the field names that can be set during ``save()``, ``insert()``, or
132138
``update()`` methods. Any field names other than these will be discarded. This helps to protect
133139
against just taking input from a form and throwing it all at the model, resulting in
134140
potential mass assignment vulnerabilities.
135141

136-
**$useTimestamps**
142+
$useTimestamps
143+
--------------
137144

138145
This boolean value determines whether the current date is automatically added to all inserts
139146
and updates. If true, will set the current time in the format specified by ``$dateFormat``. This
140147
requires that the table have columns named **created_at** and **updated_at** in the appropriate
141148
data type.
142149

143-
**$createdField**
150+
$createdField
151+
-------------
144152

145153
Specifies which database field to use for data record create timestamp.
146154
Leave it empty to avoid updating it (even if ``$useTimestamps`` is enabled).
147155

148-
**$updatedField**
156+
$updatedField
157+
-------------
149158

150159
Specifies which database field should use for keep data record update timestamp.
151160
Leave it empty to avoid update it (even ``$useTimestamps`` is enabled).
152161

153-
**$dateFormat**
162+
$dateFormat
163+
-----------
154164

155165
This value works with ``$useTimestamps`` and ``$useSoftDeletes`` to ensure that the correct type of
156166
date value gets inserted into the database. By default, this creates DATETIME values, but
157167
valid options are: ``'datetime'``, ``'date'``, or ``'int'`` (a PHP timestamp). Using **useSoftDeletes** or
158-
**useTimestamps** with an invalid or missing dateFormat will cause an exception.
168+
useTimestamps with an invalid or missing dateFormat will cause an exception.
159169

160-
**$validationRules**
170+
$validationRules
171+
----------------
161172

162173
Contains either an array of validation rules as described in :ref:`validation-array`
163174
or a string containing the name of a validation group, as described in the same section.
164175
Described in more detail below.
165176

166-
**$validationMessages**
177+
$validationMessages
178+
-------------------
167179

168180
Contains an array of custom error messages that should be used during validation, as
169181
described in :ref:`validation-custom-errors`. Described in more detail below.
170182

171-
**$skipValidation**
183+
$skipValidation
184+
---------------
172185

173186
Whether validation should be skipped during all **inserts** and **updates**. The default
174187
value is false, meaning that data will always attempt to be validated. This is
175188
primarily used by the ``skipValidation()`` method, but may be changed to ``true`` so
176189
this model will never validate.
177190

178-
**$beforeInsert**
179-
**$afterInsert**
180-
**$beforeUpdate**
181-
**$afterUpdate**
182-
**$afterFind**
183-
**$afterDelete**
191+
$beforeInsert
192+
-------------
193+
$afterInsert
194+
------------
195+
$beforeUpdate
196+
-------------
197+
$afterUpdate
198+
------------
199+
$afterFind
200+
----------
201+
$afterDelete
202+
------------
184203

185204
These arrays allow you to specify callback methods that will be run on the data at the
186205
time specified in the property name.
187206

188-
**$allowCallbacks**
207+
$allowCallbacks
208+
---------------
189209

190210
Whether the callbacks defined above should be used.
191211

@@ -198,7 +218,8 @@ Finding Data
198218
Several functions are provided for doing basic CRUD work on your tables, including ``find()``,
199219
``insert()``, ``update()``, ``delete()`` and more.
200220

201-
**find()**
221+
find()
222+
------
202223

203224
Returns a single row where the primary key matches the value passed in as the first parameter:
204225

@@ -214,15 +235,17 @@ of just one:
214235
If no parameters are passed in, will return all rows in that model's table, effectively acting
215236
like ``findAll()``, though less explicit.
216237

217-
**findColumn()**
238+
findColumn()
239+
------------
218240

219241
Returns null or an indexed array of column values:
220242

221243
.. literalinclude:: model/008.php
222244

223245
``$column_name`` should be a name of single column else you will get the DataException.
224246

225-
**findAll()**
247+
findAll()
248+
---------
226249

227250
Returns all results:
228251

@@ -237,20 +260,23 @@ parameters, respectively:
237260

238261
.. literalinclude:: model/011.php
239262

240-
**first()**
263+
first()
264+
-------
241265

242266
Returns the first row in the result set. This is best used in combination with the query builder.
243267

244268
.. literalinclude:: model/012.php
245269

246-
**withDeleted()**
270+
withDeleted()
271+
-------------
247272

248273
If ``$useSoftDeletes`` is true, then the **find*()** methods will not return any rows where 'deleted_at IS NOT NULL'.
249274
To temporarily override this, you can use the ``withDeleted()`` method prior to calling the **find*()** method.
250275

251276
.. literalinclude:: model/013.php
252277

253-
**onlyDeleted()**
278+
onlyDeleted()
279+
-------------
254280

255281
Whereas ``withDeleted()`` will return both deleted and not-deleted rows, this method modifies
256282
the next **find*()** methods to return only soft deleted rows:
@@ -260,15 +286,17 @@ the next **find*()** methods to return only soft deleted rows:
260286
Saving Data
261287
===========
262288

263-
**insert()**
289+
insert()
290+
--------
264291

265292
An associative array of data is passed into this method as the only parameter to create a new
266293
row of data in the database. The array's keys must match the name of the columns in a ``$table``, while
267294
the array's values are the values to save for that key:
268295

269296
.. literalinclude:: model/015.php
270297

271-
**update()**
298+
update()
299+
--------
272300

273301
Updates an existing record in the database. The first parameter is the ``$primaryKey`` of the record to update.
274302
An associative array of data is passed into this method as the second parameter. The array's keys must match the name
@@ -285,7 +313,8 @@ update command, with the added benefit of validation, events, etc:
285313

286314
.. literalinclude:: model/018.php
287315

288-
**save()**
316+
save()
317+
------
289318

290319
This is a wrapper around the ``insert()`` and ``update()`` methods that handle inserting or updating the record
291320
automatically, based on whether it finds an array key matching the **primary key** value:
@@ -318,7 +347,8 @@ model's ``save()`` method to inspect the class, grab any public and private prop
318347
Deleting Data
319348
=============
320349

321-
**delete()**
350+
delete()
351+
--------
322352

323353
Takes a primary key value as the first parameter and deletes the matching record from the model's table:
324354

@@ -336,7 +366,8 @@ previously:
336366

337367
.. literalinclude:: model/025.php
338368

339-
**purgeDeleted()**
369+
purgeDeleted()
370+
--------------
340371

341372
Cleans out the database table by permanently removing all rows that have 'deleted_at IS NOT NULL'.
342373

@@ -510,13 +541,15 @@ provides methods that allow you to do just that.
510541
.. note:: These methods only change the return type for the next **find*()** method call. After that,
511542
it is reset to its default value.
512543

513-
**asArray()**
544+
asArray()
545+
---------
514546

515547
Returns data from the next **find*()** method as associative arrays:
516548

517549
.. literalinclude:: model/047.php
518550

519-
**asObject()**
551+
asObject()
552+
----------
520553

521554
Returns data from the next **find*()** method as standard objects or custom class intances:
522555

0 commit comments

Comments
 (0)