Skip to content

Commit

Permalink
orm chapter wording and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian committed Jun 13, 2016
1 parent a18a5ea commit ccacdfb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions developer-basics/orm.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class Topic
```

A few things to note:
A model is a plain PHP class that uses the trait `Pagekit\Database\ORM\ModelTrait`. Traits allow to include certain behaviour into a class - similar to simple class inheritance. The main difference is that a class can use multiple traits while it could only inherit from one single class.

A model is a plain PHP class uses the trait `Pagekit\Database\ORM\ModelTrait`. If you are unfamiliar with traits, have a quick looks at the [official PHP documentation on traits](http://php.net/manual/en/language.oop5.traits.php). Basically it is a concept to pull certain behaviour into a class - similar to simple class inheritance. The main difference is that a class can use multiple traits while it could only inherit from one single class.
**Note** If you are unfamiliar with traits, have a quick look at the [official PHP documentation on traits](http://php.net/manual/en/language.oop5.traits.php).

The annotation `@Entity(tableClass="@my_table")` binds the Model to the database table `pk_my_table` (`@` is automatically replaced by the database prefix of your installation )

Expand All @@ -94,7 +94,6 @@ When defining a property in a class, you can bind that variable to a table colum

The class you reference in your model class also has to exist in the database.


## Relations

The application data you represent in your database model has certain relations amongst its instances. A blog post has a number of comments related to it and it belongs to exactly one User instance. The Pagekit ORM offers mechanisms to define these relations and also to query them in a programmatic manner.
Expand Down Expand Up @@ -361,11 +360,13 @@ The relation itself is then defined in each Model class where you want to be abl

The `@ManyToMany` annotation takes the following parameters.

- `targetEntity`: The target model class
- `tableThrough` Name of the junction table
- `keyThroughFrom` Name of the foreign key in "from" direction
- `keyThroughTo` Name of the foreign key in "to" direction
- `orderBy` (optional) Order by statement
Argument | Description
---------------- | -----------
`targetEntity` | The target model class
`tableThrough` | Name of the junction table
`keyThroughFrom` | Name of the foreign key in "from" direction
`keyThroughTo` | Name of the foreign key in "to" direction
`orderBy` | (optional) Order by statement

Example annotation:

Expand Down

0 comments on commit ccacdfb

Please sign in to comment.