Skip to content

Commit 43faacc

Browse files
authored
Merge pull request #5120 from okinaka/3.0-ja-update
[ja] follows #5102, #5103, #5104, #5115
2 parents 9af90ff + e097039 commit 43faacc

File tree

3 files changed

+11
-40
lines changed

3 files changed

+11
-40
lines changed

ja/orm/behaviors/tree.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ CakePHP は内部構造を構築することができます。 ::
6767
echo $category->name . "\n";
6868
}
6969

70+
条件を渡す必要がある場合は、通常通り::
71+
72+
$descendants = $categories
73+
->find('children', ['for' => 1])
74+
->where(['name LIKE' => '%Foo%']);
75+
76+
foreach ($descendants as $category) {
77+
echo $category->name . "\n";
78+
}
79+
7080
代わりに、各ノードの子が階層内にネストされているスレッドリストが必要な場合は、
7181
'threaded' ファインダを積み重ねられます。 ::
7282

ja/orm/database-basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Select 文の実行
6565
$results = $connection
6666
->execute(
6767
'SELECT * FROM articles WHERE created >= :created',
68-
['created' => DateTime('1 day ago')],
68+
['created' => new DateTime('1 day ago')],
6969
['created' => 'datetime']
7070
)
7171
->fetchAll('assoc');

ja/orm/saving-data.rst

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -101,45 +101,6 @@ CakePHP は挿入または更新のいずれの処理を行うかを ``isNew()``
101101

102102
$articlesTable->Tags->link($article, [$tag1, $tag2]);
103103

104-
結合用テーブルへのデータ保存
105-
----------------------------
106-
107-
結合用テーブルへのデータ保存は、特別な ``_joinData`` プロパティーを使用して行われます。
108-
このプロパティーは結合用の Table クラスの ``Entity`` インスタンスになっているはずです。 ::
109-
110-
// 最初にレコードを紐付けます。
111-
$tag1 = $articlesTable->Tags->findByName('cakephp')->first();
112-
$tag1->_joinData = $articlesTable->ArticlesTags->newEntity();
113-
$tag1->_joinData->tagComment = 'CakePHP の ORM は実に強力です!';
114-
115-
$articlesTable->Tags->link($article, [$tag1]);
116-
117-
// 既存のアソシエーションを更新します。
118-
$article = $articlesTable->get(1, ['contain' => ['Tags']]);
119-
$article->tags[0]->_joinData->tagComment = '新しいコメント。'
120-
121-
// 必須です。なぜならプロパティーを直接変更しているからです。
122-
$article->dirty('tags', true);
123-
124-
$articlesTable->save($article, ['associated' => ['Tags']]);
125-
126-
``newEntity()`` や ``patchEntity()`` を使う時に、結合用テーブルの情報もまた
127-
作成/更新することができます。 POST データはこうなります。 ::
128-
129-
$data = [
130-
'title' => '私の素晴らしいブログ投稿',
131-
'body' => '何かのコンテンツが少し続きます。',
132-
'tags' => [
133-
[
134-
'id' => 10,
135-
'_joinData' => [
136-
'tagComment' => '素晴らしい記事です!',
137-
]
138-
],
139-
]
140-
];
141-
$articlesTable->newEntity($data, ['associated' => ['Tags']]);
142-
143104
多対多レコードの紐付け解除
144105
--------------------------
145106

0 commit comments

Comments
 (0)