Skip to content

Commit 4ad1edf

Browse files
committed
docs: fix heading underline level
1 parent 491fe59 commit 4ad1edf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

user_guide_src/source/models/model.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Using CodeIgniter's Model
77
:depth: 2
88

99
Models
10-
======
10+
******
1111

1212
The CodeIgniter's Model provides convenience features and additional functionality
1313
that people commonly use to make working with a **single table** in your database more convenient.
@@ -17,7 +17,7 @@ methods for much of the standard ways you would need to interact with a database
1717
updating records, deleting records, and more.
1818

1919
Accessing Models
20-
================
20+
****************
2121

2222
Models are typically stored in the ``app/Models`` directory. They should have a namespace that matches their
2323
location within the directory, like ``namespace App\Models``.
@@ -27,7 +27,7 @@ You can access models within your classes by creating a new instance or using th
2727
.. literalinclude:: model/001.php
2828

2929
CodeIgniter's Model
30-
===================
30+
*******************
3131

3232
CodeIgniter does provide a model class that provides a few nice features, including:
3333

@@ -41,7 +41,7 @@ This class provides a solid base from which to build your own models, allowing y
4141
rapidly build out your application's model layer.
4242

4343
Creating Your Model
44-
===================
44+
*******************
4545

4646
To take advantage of CodeIgniter's model, you would simply create a new model class
4747
that extends ``CodeIgniter\Model``:
@@ -58,7 +58,7 @@ extra steps without repeating the constructor parameters, for example extending
5858
.. literalinclude:: model/003.php
5959

6060
Connecting to the Database
61-
--------------------------
61+
==========================
6262

6363
When the class is first instantiated, if no database connection instance is passed to the constructor,
6464
it will automatically connect to the default database group, as set in the configuration. You can
@@ -72,7 +72,7 @@ You would replace "group_name" with the name of a defined database group from th
7272
configuration file.
7373

7474
Configuring Your Model
75-
----------------------
75+
======================
7676

7777
The model class has a few configuration options that can be set to allow the class' methods
7878
to work seamlessly for you. The first two are used by all of the CRUD methods to determine
@@ -190,10 +190,10 @@ time specified in the property name.
190190
Whether the callbacks defined above should be used.
191191

192192
Working With Data
193-
=================
193+
*****************
194194

195195
Finding Data
196-
------------
196+
============
197197

198198
Several functions are provided for doing basic CRUD work on your tables, including ``find()``,
199199
``insert()``, ``update()``, ``delete()`` and more.
@@ -258,7 +258,7 @@ the next **find*()** methods to return only soft deleted rows:
258258
.. literalinclude:: model/014.php
259259

260260
Saving Data
261-
-----------
261+
===========
262262

263263
**insert()**
264264

@@ -316,7 +316,7 @@ model's ``save()`` method to inspect the class, grab any public and private prop
316316
that provides several handy features that make developing Entities simpler.
317317

318318
Deleting Data
319-
-------------
319+
=============
320320

321321
**delete()**
322322

@@ -343,7 +343,7 @@ Cleans out the database table by permanently removing all rows that have 'delete
343343
.. literalinclude:: model/026.php
344344

345345
Validating Data
346-
---------------
346+
===============
347347

348348
For many people, validating data in the model is the preferred way to ensure the data is kept to a single
349349
standard, without duplicating code. The Model class provides a way to automatically have all data validated
@@ -416,7 +416,7 @@ and simply set ``$validationRules`` to the name of the validation rule group you
416416
.. literalinclude:: model/034.php
417417

418418
Retrieving Validation Rules
419-
---------------------------
419+
===========================
420420

421421
You can retrieve a model's validation rules by accessing its ``validationRules``
422422
property:
@@ -435,7 +435,7 @@ value an array of fieldnames of interest:
435435
.. literalinclude:: model/037.php
436436

437437
Validation Placeholders
438-
-----------------------
438+
=======================
439439

440440
The model provides a simple method to replace parts of your rules based on data that's being passed into it. This
441441
sounds fairly obscure but can be especially handy with the ``is_unique`` validation rule. Placeholders are simply
@@ -459,7 +459,7 @@ This can also be used to create more dynamic rules at runtime, as long as you ta
459459
keys passed in don't conflict with your form data.
460460

461461
Protecting Fields
462-
-----------------
462+
=================
463463

464464
To help protect against Mass Assignment Attacks, the Model class **requires** that you list all of the field names
465465
that can be changed during inserts and updates in the ``$allowedFields`` class property. Any data provided
@@ -474,7 +474,7 @@ testing, migrations, or seeds. In these cases, you can turn the protection on or
474474
.. literalinclude:: model/042.php
475475

476476
Working With Query Builder
477-
--------------------------
477+
==========================
478478

479479
You can get access to a shared instance of the Query Builder for that model's database connection any time you
480480
need it:
@@ -501,7 +501,7 @@ very elegant use:
501501
.. literalinclude:: model/046.php
502502

503503
Runtime Return Type Changes
504-
----------------------------
504+
===========================
505505

506506
You can specify the format that data should be returned as when using the **find*()** methods as the class property,
507507
``$returnType``. There may be times that you would like the data back in a different format, though. The Model
@@ -523,7 +523,7 @@ Returns data from the next **find*()** method as standard objects or custom clas
523523
.. literalinclude:: model/048.php
524524

525525
Processing Large Amounts of Data
526-
--------------------------------
526+
================================
527527

528528
Sometimes, you need to process large amounts of data and would run the risk of running out of memory.
529529
To make this simpler, you may use the chunk() method to get smaller chunks of data that you can then
@@ -535,15 +535,15 @@ This is best used during cronjobs, data exports, or other large tasks.
535535
.. literalinclude:: model/049.php
536536

537537
Model Events
538-
============
538+
************
539539

540540
There are several points within the model's execution that you can specify multiple callback methods to run.
541541
These methods can be used to normalize data, hash passwords, save related entities, and much more. The following
542542
points in the model's execution can be affected, each through a class property: ``$beforeInsert``, ``$afterInsert``,
543543
``$beforeUpdate``, ``$afterUpdate``, ``$afterFind``, and ``$afterDelete``.
544544

545545
Defining Callbacks
546-
------------------
546+
==================
547547

548548
You specify the callbacks by first creating a new class method in your model to use. This class will always
549549
receive a ``$data`` array as its only parameter. The exact contents of the ``$data`` array will vary between events, but
@@ -555,7 +555,7 @@ must return the original $data array so other callbacks have the full informatio
555555
.. literalinclude:: model/050.php
556556

557557
Specifying Callbacks To Run
558-
---------------------------
558+
===========================
559559

560560
You specify when to run the callbacks by adding the method name to the appropriate class property (``$beforeInsert``, ``$afterUpdate``,
561561
etc). Multiple callbacks can be added to a single event and they will be processed one after the other. You can
@@ -572,7 +572,7 @@ You may also change this setting temporarily for a single model call sing the ``
572572
.. literalinclude:: model/053.php
573573

574574
Event Parameters
575-
----------------
575+
================
576576

577577
Since the exact data passed to each callback varies a bit, here are the details on what is in the ``$data`` parameter
578578
passed to each event:
@@ -607,7 +607,7 @@ afterDelete **id** = primary key of row being deleted.
607607
================ =========================================================================================================
608608

609609
Modifying Find* Data
610-
--------------------
610+
====================
611611

612612
The ``beforeFind`` and ``afterFind`` methods can both return a modified set of data to override the normal response
613613
from the model. For ``afterFind`` any changes made to ``data`` in the return array will automatically be passed back
@@ -617,7 +617,7 @@ boolean, ``returnData``:
617617
.. literalinclude:: model/054.php
618618

619619
Manual Model Creation
620-
=====================
620+
*********************
621621

622622
You do not need to extend any special class to create a model for your application. All you need is to get an
623623
instance of the database connection and you're good to go. This allows you to bypass the features CodeIgniter's

0 commit comments

Comments
 (0)