forked from fuel/docs
-
Notifications
You must be signed in to change notification settings - Fork 119
/
qb_where.html
508 lines (461 loc) · 14.3 KB
/
qb_where.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./../../assets/css/combined.css">
<link rel="shortcut icon" href="./../../favicon.ico" />
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
var path = './../../';
var class_prefix = 'Query_Builder_Where::';
</script>
<script src="./../../assets/js/combined.js"></script>
<title>Query Builder Where - クラス - FuelPHP ドキュメント</title>
</head>
<body>
<div id="container">
<header id="header">
<div class="table">
<h1>
<strong>FuelPHP, a PHP 5.3 Framework</strong>
Documentation
</h1>
<form id="google_search">
<p>
<span id="search_clear"> </span>
<input type="submit" name="search_submit" id="search_submit" value="検索" />
<input type="text" value="" id="search_input" name="search_input" />
</p>
</form>
</div>
<nav>
<div class="clear"></div>
</nav>
<a href="#" id="toc_handle">目次</a>
<div class="clear"></div>
</header>
<div id="cse">
<div id="cse_point"></div>
<div id="cse_content"></div>
</div>
<div id="main">
<h2 id="introduction">Query_Builder_Where クラス</h2>
<p>
<strong>Query_Builder_Where</strong> クラスは、クエリ構築における条件及び制限を設定するロジックを扱います。
すべての種類の where ステートメント (BETWEEN や IN などを含む) はここで扱います。このクラスは、抽象クラスのためインスタンスは生成できず、同じ機能を共有する他のクラスに継承されます。
それらのクラスは次のとおりです。:
</p>
<ul>
<li><a href="qb_select.html">Query_Builder_Select</a></li>
<li><a href="qb_update.html">Query_Builder_Update</a></li>
<li><a href="qb_delete.html">Query_Builder_Delete</a></li>
</ul>
<p id="returned_instance" class="note">
<strong>注意:</strong> Query_Builder_Where は上記のクラスから継承されるため、"current instance" はそれらの一つが返却されます。
</p>
<article>
<h4 class="method" id="method_where">where()</h4>
<p><strong>where</strong> メソッドは<a href="#method_and_where">and_where</a>のエイリアスです。</p>
</article>
<article>
<h4 class="method" id="method_and_where">and_where($column, $op = null, $value = null)</h4>
<p><strong>and_where</strong> メソッドは、WHERE ステートメントを追加します。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>型</th>
<th>規定値</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$column</kbd></th>
<td><em>mixed</em></td>
<td><em>必須</em></td>
<td>Column name or array($column, $alias), object, or callback</td>
</tr>
<tr>
<th><kbd>$op</kbd></th>
<td><em>string</em></td>
<td><pre class="php"><code>null</code></pre></td>
<td>Logic operator: =, !=, IN, BETWEEN and LIKE. If none is provided this will fallback to '='</td>
</tr>
<tr>
<th><kbd>$value</kbd></th>
<td><em>string</em></td>
<td><pre class="php"><code>null</code></pre></td>
<td>カラムの値</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// 最初の where ステートメントをセット
$query->where('name', '!=', 'John');
// あたらしい条件を追加
$query->and_where('surname', 'Doe');
// ネストした where をコールバックで
$query->where(function($query){
$query->where('email', 'jim@jim.com')
->or_where('email', 'haha@joke.com');
});
// 結果:
// SELECT * FROM `users` WHERE `name` != "John" AND `surname` = "Doe"
// AND (`email` = "jim@jim.com" OR `email` = "haha@joke.com")
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_or_where">or_where($column, $op = null, $value = null)</h4>
<p><strong>or_where</strong> メソッドは OR WHERE ステートメントを追加します。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>型</th>
<th>規定値</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$column</kbd></th>
<td><em>string</em></td>
<td><em>必須</em></td>
<td>Column name or array($column, $alias), object or callback</td>
</tr>
<tr>
<th><kbd>$op</kbd></th>
<td><em>string</em></td>
<td><pre class="php"><code>null</code></pre></td>
<td>Logic operator: =, !=, IN, BETWEEN. If none is provided this will fallback to '='</td>
</tr>
<tr>
<th><kbd>$value</kbd></th>
<td><em>string</em></td>
<td><pre class="php"><code>null</code></pre></td>
<td>カラムの値</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// 最初の where ステートメントをセット
$query->where('name', '=', 'John');
// あたらしい条件を追加
$query->or_where('surname', 'Doe');
// nested where through callback
$query->or_where(function($query){
$query->where('email', 'jim@jim.com')
->and_where('id', 4);
});
// Resulting in:
// SELECT * FROM `users` WHERE `name` != "John" OR `surname` = "Doe"
// OR (`email` = "jim@jim.com" AND `id` = 4)
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_where_open">where_open()</h4>
<p><strong>where_open</strong> メソッドは、<a href="#method_and_where_open">and_where_open</a>のエイリアスです。</p>
</article>
<article>
<h4 class="method" id="method_and_where_open">and_where_open()</h4>
<p><strong>and_where_open</strong> メソッドは、 SQL クロージャ を開き、それを AND で追加します。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<em>None</em>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// where ステートメントをセット
$query->where('name', 'john');
// クロージャを開く
$query->and_where_open();
// SELECT * FROM `users` WHERE `name` = "John" AND (
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_or_where_open">or_where_open()</h4>
<p><strong>or_where_open</strong> メソッドは SQL クロージャを開き、それを OR で追加します。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<em>None</em>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// where ステートメントをセット
$query->where('name', 'john');
// クロージャを開く
$query->or_where_open();
// SELECT * FROM `users` WHERE `name` = "John" OR (
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_where_close">where_close()</h4>
<p><strong>where_close</strong> メソッドは <a href="#method_and_where_close">and_where_close</a>のエイリアスです。</p>
</article>
<article>
<h4 class="method" id="method_and_where_close">and_where_close()</h4>
<p><strong>and_where_close</strong> メソッドは、SQL クロージャを閉じます。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<em>None</em>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// where ステートメントをセット
$query->where('email', 'like', '%@example.com');
// クロージャを開く
$query->and_where_open();
// where ステートメントをセット
$query->where('name', 'John');
$query->or_where('surname', 'Doe');
$query->and_where_close();
// SELECT * FROM `users`
// WHERE `email` LIKE "%example.com" AND (`name` = "John" OR `surname` = "Doe")
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_or_where_close">or_where_close()</h4>
<p><strong>or_where_close</strong> メソッドは、SQL クロージャを閉じます。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<em>None</em>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// where ステートメントをセット
$query->where('email', 'like', '%@example.com');
// クロージャを開く
$query->or_where_open();
// where ステートメントをセット
$query->where('name', 'John');
$query->and_where('surname', 'Doe');
$query->or_where_close();
// SELECT * FROM `users` WHERE `email` LIKE "%example.com" OR (`name` = "John" AND `surname` = "Doe")
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_order_by">order_by($column, $direction = NULL)</h4>
<p><strong>order_by</strong> メソッドは、結果/実行の順序をセットします。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>型</th>
<th>規定値</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$column</kbd></th>
<td><em>string</em></td>
<td><em>必須</em></td>
<td>カラム名</td>
</tr>
<tr>
<th><kbd>$direction</kbd></th>
<td><em>string</em></td>
<td><em>null</em></td>
<td> <em>'asc'</em> もしくは <em>'desc'</em>が指定可能です。</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// order by をセット
$query->order_by('name');
$query->order_by('email', 'asc');
$query->order_by('surname', 'desc');
// SELECT * FROM `users` ORDER BY `name`, `email` ASC, `surname DESC
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_limit">limit($number)</h4>
<p><strong>limit</strong> メソッドは、 取得/更新する、レコード数の上限をセットします。</p>
<table class="method">
<tbody>
<tr>
<th>静的</th>
<td>No</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>型</th>
<th>規定値</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$number</kbd></th>
<td><em>int</em></td>
<td><em>必須</em></td>
<td>The number of rows</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>Returns the <a href="#returned_instance">current instance</a>.</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>// prepare a select statement
$query = DB::select('*')->from('users');
// limit句をセット
$query->limit(10);
// SELECT * FROM `users` LIMIT 10
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
</div>
<footer>
<p>
© FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
[ <a href="https://github.com/fuel/docs/commits/1.5/develop/classes/database/qb_where.html">原文コミット履歴</a> | <a href="https://github.com/NEKOGET/FuelPHP_docs_jp/commits/1.5/develop_japanese/classes/database/qb_where.html">翻訳コミット履歴</a> | <a href="https://github.com/NEKOGET/FuelPHP_docs_jp/blob/1.5/develop_japanese/classes/database/qb_where.html">GitHubで修正</a> ]
</p>
</footer>
</div>
</body>
</html>