回答編集履歴
1
加筆修正
test
CHANGED
@@ -13,3 +13,27 @@
|
|
13
13
|
その際、[ヒアドキュメント](https://www.php.net/manual/ja/language.types.string.php#language.types.string.syntax.heredoc)構文も駆使して、
|
14
14
|
|
15
15
|
読みやすいSQLクエリーにするとよいかと。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```php
|
20
|
+
|
21
|
+
$sql = <<<EOT
|
22
|
+
|
23
|
+
SELECT TO_CHAR(y.yoyaku_date,'YYYY-FMMM-FMDD') AS yoyaku_date, s.sname, y.start_time, y.end_time
|
24
|
+
|
25
|
+
FROM tbl_4_2_1 AS y INNER JOIN tbl_4_2_2 AS s ON y.scode = s.scode
|
26
|
+
|
27
|
+
WHERE TO_DATE(y.yoyaku_date,'YYYY-MM')=TO_DATE($1,'YYYY-MM')
|
28
|
+
|
29
|
+
ORDER BY s.scode,y.start_time,y.end_time;
|
30
|
+
|
31
|
+
EOT;
|
32
|
+
|
33
|
+
$result = pg_prepare($con, 'query', $sql);
|
34
|
+
|
35
|
+
$result = pg_execute($con, 'query', array($year . '-' . $month));
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
(あくまで机上のコードなので、エラーが出たらご指摘を。)
|