回答編集履歴
1
回答を追記
test
CHANGED
@@ -11,3 +11,35 @@
|
|
11
11
|
[http://monmon.hateblo.jp/entry/20120507/1336375838](http://monmon.hateblo.jp/entry/20120507/1336375838)
|
12
12
|
|
13
13
|
[http://cakebaker.42dh.com/2008/06/10/order-by-field/](http://cakebaker.42dh.com/2008/06/10/order-by-field/)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
```php
|
20
|
+
|
21
|
+
$id = array(1, 6, 4, 5, 10);
|
22
|
+
|
23
|
+
$order = array('FIELD(id, ' . implode(', ', $id) . ')');
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
print_r($order);
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
実行結果
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
Array
|
36
|
+
|
37
|
+
(
|
38
|
+
|
39
|
+
[0] => FIELD(id, 1, 6, 4, 5, 10)
|
40
|
+
|
41
|
+
)
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
[http://php.net/manual/ja/function.implode.php](http://php.net/manual/ja/function.implode.php)
|