質問編集履歴
3
関数全文追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,38 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
```php
|
10
|
+
|
11
|
+
function update_active_days($dbh, $active_day_str){
|
12
|
+
|
13
|
+
$sql = 'SELECT column_name from information_schema.columns where table_name = "schedule"';
|
14
|
+
|
15
|
+
$stmt = $dbh->prepare($sql);
|
16
|
+
|
17
|
+
$stmt->execute();
|
18
|
+
|
19
|
+
$column_name = array_map('current', $stmt->fetchAll());
|
20
|
+
|
21
|
+
//カラム名”id”を配列から削除
|
22
|
+
|
23
|
+
while(($index = array_search("id", $column_name, true )) !== false ) {
|
24
|
+
|
25
|
+
unset($column_name[$index]) ;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
//カラム名の差分を取ってキーを0から始まる連番に振り直す
|
30
|
+
|
31
|
+
$column_name_diff_old = array_values(array_diff($column_name, $active_day_str));
|
32
|
+
|
33
|
+
$column_name_diff_new = array_values(array_diff($active_day_str, $column_name));
|
34
|
+
|
35
|
+
$cnt = count($column_name_diff_old);
|
36
|
+
|
37
|
+
if ($cnt == 0){
|
38
|
+
|
39
|
+
exit;
|
40
|
+
|
41
|
+
}elseif($cnt > 0){
|
10
42
|
|
11
43
|
for ($i=0; $i < $cnt; $i++){
|
12
44
|
|
@@ -18,6 +50,8 @@
|
|
18
50
|
|
19
51
|
}
|
20
52
|
|
53
|
+
}
|
54
|
+
|
21
55
|
}
|
22
56
|
|
23
57
|
```
|
2
エラー文追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,9 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
```
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
エラー
|
28
|
+
|
29
|
+
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''2018-09-01'' at line 1 in
|
1
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|