回答編集履歴
7
変更
answer
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
|
12
12
|
$arr_pop = array_pop($result);
|
13
13
|
if(strpos($arr_pop,'FOREIGN KEY')){
|
14
|
-
|
14
|
+
//外部キー制約がある場合の処理
|
15
15
|
}else{
|
16
|
-
|
16
|
+
//ない場合の処理
|
17
17
|
}
|
18
18
|
|
19
19
|
}
|
@@ -24,8 +24,8 @@
|
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
27
|
-
$
|
27
|
+
$fkey = new ForeignKey();
|
28
|
-
$
|
28
|
+
$fkey->getQuery();
|
29
29
|
function array_flatten($array){
|
30
30
|
$result = array();
|
31
31
|
foreach((array)$array as $val){
|
6
変更
answer
CHANGED
@@ -8,11 +8,13 @@
|
|
8
8
|
$sql->execute();
|
9
9
|
$result = $sql->fetch(PDO::FETCH_ASSOC);
|
10
10
|
$result = array_flatten($result);
|
11
|
+
|
12
|
+
$arr_pop = array_pop($result);
|
11
|
-
if(
|
13
|
+
if(strpos($arr_pop,'FOREIGN KEY')){
|
12
|
-
|
14
|
+
echo 'hit';
|
13
15
|
}else{
|
14
|
-
|
16
|
+
echo 'none';
|
15
|
-
}
|
17
|
+
}
|
16
18
|
|
17
19
|
}
|
18
20
|
catch(PDOException $e){
|
@@ -37,5 +39,3 @@
|
|
37
39
|
}
|
38
40
|
|
39
41
|
```
|
40
|
-
|
41
|
-
↑のコードだとたぶんヒットしませんが、foreachで回して、配列ごとにFOREIGNとかで検索かけるように修正すれば動くと思います。
|
5
追記
answer
CHANGED
@@ -36,4 +36,6 @@
|
|
36
36
|
return $result;
|
37
37
|
}
|
38
38
|
|
39
|
-
```
|
39
|
+
```
|
40
|
+
|
41
|
+
↑のコードだとたぶんヒットしませんが、foreachで回して、配列ごとにFOREIGNとかで検索かけるように修正すれば動くと思います。
|
4
追記
answer
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
try{
|
6
6
|
|
7
7
|
$sql = $this->db->prepare("show create table tablename");
|
8
|
-
|
8
|
+
$sql->execute();
|
9
9
|
$result = $sql->fetch(PDO::FETCH_ASSOC);
|
10
10
|
$result = array_flatten($result);
|
11
11
|
if(!array_search('FOREIGN KEY',$result)){
|
3
追記
answer
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
try{
|
6
6
|
|
7
7
|
$sql = $this->db->prepare("show create table tablename");
|
8
|
-
|
8
|
+
|
9
9
|
$result = $sql->fetch(PDO::FETCH_ASSOC);
|
10
10
|
$result = array_flatten($result);
|
11
11
|
if(!array_search('FOREIGN KEY',$result)){
|
2
追記
answer
CHANGED
@@ -16,7 +16,8 @@
|
|
16
16
|
|
17
17
|
}
|
18
18
|
catch(PDOException $e){
|
19
|
-
$
|
19
|
+
print('Error:'.$e->getMessage());
|
20
|
+
die();
|
20
21
|
}
|
21
22
|
}
|
22
23
|
}
|
1
追記
answer
CHANGED
@@ -13,8 +13,7 @@
|
|
13
13
|
}else{
|
14
14
|
print 'Hit';
|
15
15
|
}
|
16
|
-
|
16
|
+
|
17
|
-
//$json_pos = str
|
18
17
|
}
|
19
18
|
catch(PDOException $e){
|
20
19
|
$pdo->rollback();
|