Skip to content

Commit 16385af

Browse files
author
rotexdegba
committed
Documentation in progress
1 parent 2f8901c commit 16385af

1 file changed

Lines changed: 39 additions & 28 deletions

File tree

docs/more-about-models.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
# More about Models
22

3-
- [Methods for Fetching data from the Database](#methods-for-fetching-data-from-the-database)
4-
- [Fetching data from the Database via fetchCol](#fetching-data-from-the-database-via-fetchcol)
5-
- [Fetching data from the Database via fetchOneRecord](#fetching-data-from-the-database-via-fetchonerecord)
6-
- [Fetching data from the Database via fetchOneByPkey](#fetching-data-from-the-database-via-fetchonebypkey)
7-
- [Fetching data from the Database via fetchPairs](#fetching-data-from-the-database-via-fetchpairs)
8-
- [Fetching data from the Database via fetchRecordsIntoArray](#fetching-data-from-the-database-via-fetchrecordsintoarray)
9-
- [Fetching data from the Database via fetchRecordsIntoArrayKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrecordsintoarraykeyedonpkval)
10-
- [Fetching data from the Database via fetchRecordsIntoCollection](#fetching-data-from-the-database-via-fetchrecordsintocollection)
11-
- [Fetching data from the Database via fetchRecordsIntoCollectionKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrecordsintocollectionkeyedonpkval)
12-
- [Fetching data from the Database via fetchRowsIntoArray](#fetching-data-from-the-database-via-fetchrowsintoarray)
13-
- [Fetching data from the Database via fetchRowsIntoArrayKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrowsintoarraykeyedonpkval)
14-
- [Fetching data from the Database via fetchValue](#fetching-data-from-the-database-via-fetchvalue)
15-
- [Fetching data from the Database via fetch](#fetching-data-from-the-database-via-fetch)
16-
- [Deleting Data](#deleting-data)
17-
- [Updating Data](#updating-data)
18-
- [Defining Relationships between Models and Working with Related Data](#defining-relationships-between-models-and-working-with-related-data)
19-
- [Belongs To](#belongs-to)
20-
- [Has One](#has-one)
21-
- [Has Many](#has-many)
22-
- [Has Many Through](#has-many-through-aka-many-to-many)
23-
- [Relationship Definition Code Samples](#relationship-definition-code-samples)
24-
- [Option 1: define the relationships for each instance after creating each instance](#option-1-define-the-relationships-for-each-instance-after-creating-each-instance)
25-
- [Option 2: define the relationships inside the constructor of each Model Class](#option-2-define-the-relationships-inside-the-constructor-of-each-model-class)
26-
- [Accessing Related Data Code Samples](#accessing-related-data-code-samples)
27-
- [Query Logging](#query-logging)
28-
29-
30-
There is **\LeanOrm\CachingModel** class that is meant to cache method return values across
3+
- [Methods for Fetching data from the Database](#methods-for-fetching-data-from-the-database)
4+
- [Fetching data from the Database via fetchCol](#fetching-data-from-the-database-via-fetchcol)
5+
- [Fetching data from the Database via fetchOneRecord](#fetching-data-from-the-database-via-fetchonerecord)
6+
- [Fetching data from the Database via fetchOneByPkey](#fetching-data-from-the-database-via-fetchonebypkey)
7+
- [Fetching data from the Database via fetchPairs](#fetching-data-from-the-database-via-fetchpairs)
8+
- [Fetching data from the Database via fetchRecordsIntoArray](#fetching-data-from-the-database-via-fetchrecordsintoarray)
9+
- [Fetching data from the Database via fetchRecordsIntoArrayKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrecordsintoarraykeyedonpkval)
10+
- [Fetching data from the Database via fetchRecordsIntoCollection](#fetching-data-from-the-database-via-fetchrecordsintocollection)
11+
- [Fetching data from the Database via fetchRecordsIntoCollectionKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrecordsintocollectionkeyedonpkval)
12+
- [Fetching data from the Database via fetchRowsIntoArray](#fetching-data-from-the-database-via-fetchrowsintoarray)
13+
- [Fetching data from the Database via fetchRowsIntoArrayKeyedOnPkVal](#fetching-data-from-the-database-via-fetchrowsintoarraykeyedonpkval)
14+
- [Fetching data from the Database via fetchValue](#fetching-data-from-the-database-via-fetchvalue)
15+
- [Fetching data from the Database via fetch](#fetching-data-from-the-database-via-fetch)
16+
- [Deleting Data](#deleting-data)
17+
- [Updating Data](#updating-data)
18+
- [Defining Relationships between Models and Working with Related Data](#defining-relationships-between-models-and-working-with-related-data)
19+
- [Belongs To](#belongs-to)
20+
- [Has One](#has-one)
21+
- [Has Many](#has-many)
22+
- [Has Many Through](#has-many-through-aka-many-to-many)
23+
- [Relationship Definition Code Samples](#relationship-definition-code-samples)
24+
- [Option 1: define the relationships for each instance after creating each instance](#option-1-define-the-relationships-for-each-instance-after-creating-each-instance)
25+
- [Option 2: define the relationships inside the constructor of each Model Class](#option-2-define-the-relationships-inside-the-constructor-of-each-model-class)
26+
- [Accessing Related Data Code Samples](#accessing-related-data-code-samples)
27+
- [Query Logging](#query-logging)
28+
29+
The Model class generates all the SQL for accessing and manipulating data in the database; it uses the DBConnector class to execute the SQL statements. The Model class together with the DBConnector class act as a Table Data Gateway.
30+
31+
The Model class also acts as a Data Mapper by being able to map:
32+
33+
- a row of data in a database table to a Record object
34+
- rows of data in a database table into a Collection object containing one or more Record objects
35+
- foreign key relationship(s) between database tables into attribute(s) of a record object. Four relationship types are supported:
36+
1. Belongs-To
37+
2. Has-One
38+
3. Has-Many
39+
4. Has-Many-Through a.k.a Many to Many)
40+
41+
There is also **\LeanOrm\CachingModel** class that is meant to cache method return values across
3142
all instances of **\LeanOrm\CachingModel** and its sub-classes (on each invocation of a php script
3243
via command line or a webserver) where possible to improve performance. You can use it instead of
3344
**\LeanOrm\Model** in your applications. The cached results do not persist between different

0 commit comments

Comments
 (0)