回答編集履歴
1
追記
answer
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
`INTO OUTFILE`を使っても、出力先はDBサーバーになります。
|
1
2
|
APサーバーに出力するのであれば、泥臭いやり方ですが、フェッチしながらファイルに書きだしてあげればどうでしょうか。
|
2
3
|
```php
|
4
|
+
$outputFile = '/test/test.txt';
|
3
5
|
$sqlStr = "SELECT test_table.id id FROM test_table tt WHERE tt.note LIKE :test";
|
4
6
|
$stmt = $conn->prepare($sqlStr);
|
5
7
|
$stmt->bindValue(':test', '%test%', PDO::PARAM_STR);
|
6
8
|
$stmt->execute($sqlStr);
|
7
|
-
$fp = fopen(
|
9
|
+
$fp = fopen($outputFile, 'w');
|
8
10
|
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
|
9
11
|
fputcsv($fp, $res);
|
10
12
|
}
|