Skip to content

Commit 0577eab

Browse files
committed
fix UnionOfRAD#32 - wrong keys in relationship documentation
1 parent 55ed24e commit 0577eab

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

en/working-with-data/relationships.wiki

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ This simple declaration relies on convention, and is the functional equivalent t
3030
<?php
3131
class Categories extends \lithium\data\Model {
3232
public $hasMany = array('Products' => array(
33-
'class' => 'Products',
34-
'key' => 'category_id',
35-
'conditions' => array(),
36-
'fields' => array(),
37-
'order' => null,
38-
'limit' => null
33+
'to' => 'Products',
34+
'key' => 'category_id',
35+
'constraints' => array(),
36+
'fields' => array(),
37+
'order' => null,
38+
'limit' => null
3939
));
4040
}
4141
?>
@@ -56,9 +56,9 @@ $categories = Categories::find('all', array(
5656
'with' => 'Products'
5757
));
5858

59-
/*
59+
/*
6060
Output of $categories->to('array'):
61-
61+
6262
Array
6363
(
6464
[id] => 1
@@ -98,7 +98,7 @@ As you can see from the output, the related data has been added on to the model
9898

9999
## Saving Related Data
100100
101-
Because Lithium's relationship setup is simple, so is saving related data. When saving related data, just make sure the proper key values are set so that the underlying data storage engine can match up the data correctly.
101+
Because Lithium's relationship setup is simple, so is saving related data. When saving related data, just make sure the proper key values are set so that the underlying data storage engine can match up the data correctly.
102102

103103
Here's a simplified example of how we'd save a newly created product, matched up to a category. First, the `ProductsController`:
104104

@@ -121,7 +121,7 @@ class ProductsController extends \lithium\action\Controller {
121121
foreach($categories as $category) {
122122
$categoryList[$category->id] = $category->name;
123123
}
124-
124+
125125
$this->set(compact('categoryList'));
126126
}
127127
}

0 commit comments

Comments
 (0)