teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

7

変更

2015/12/04 20:35

投稿

tixure55
tixure55

スコア400

answer CHANGED
@@ -11,9 +11,9 @@
11
11
 
12
12
  $arr_pop = array_pop($result);
13
13
  if(strpos($arr_pop,'FOREIGN KEY')){
14
- echo 'hit';
14
+ //外部キー制約がある場合の処理
15
15
  }else{
16
- echo 'none';
16
+ //ない場合の処理
17
17
  }
18
18
 
19
19
  }
@@ -24,8 +24,8 @@
24
24
  }
25
25
  }
26
26
 
27
- $fk = new ForeignKey();
27
+ $fkey = new ForeignKey();
28
- $fk->getQuery();
28
+ $fkey->getQuery();
29
29
  function array_flatten($array){
30
30
  $result = array();
31
31
  foreach((array)$array as $val){

6

変更

2015/12/04 20:35

投稿

tixure55
tixure55

スコア400

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(!array_search('FOREIGN KEY',$result)){
13
+ if(strpos($arr_pop,'FOREIGN KEY')){
12
- print 'None';
14
+ echo 'hit';
13
15
  }else{
14
- print 'Hit';
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

追記

2015/12/04 20:33

投稿

tixure55
tixure55

スコア400

answer CHANGED
@@ -36,4 +36,6 @@
36
36
  return $result;
37
37
  }
38
38
 
39
- ```
39
+ ```
40
+
41
+ ↑のコードだとたぶんヒットしませんが、foreachで回して、配列ごとにFOREIGNとかで検索かけるように修正すれば動くと思います。

4

追記

2015/12/04 20:21

投稿

tixure55
tixure55

スコア400

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

追記

2015/12/04 20:13

投稿

tixure55
tixure55

スコア400

answer CHANGED
@@ -5,7 +5,7 @@
5
5
  try{
6
6
 
7
7
  $sql = $this->db->prepare("show create table tablename");
8
- $sql->execute();
8
+
9
9
  $result = $sql->fetch(PDO::FETCH_ASSOC);
10
10
  $result = array_flatten($result);
11
11
  if(!array_search('FOREIGN KEY',$result)){

2

追記

2015/12/04 20:07

投稿

tixure55
tixure55

スコア400

answer CHANGED
@@ -16,7 +16,8 @@
16
16
 
17
17
  }
18
18
  catch(PDOException $e){
19
- $pdo->rollback();
19
+ print('Error:'.$e->getMessage());
20
+ die();
20
21
  }
21
22
  }
22
23
  }

1

追記

2015/12/04 19:56

投稿

tixure55
tixure55

スコア400

answer CHANGED
@@ -13,8 +13,7 @@
13
13
  }else{
14
14
  print 'Hit';
15
15
  }
16
- $result_json = json_encode($result);
16
+
17
- //$json_pos = str
18
17
  }
19
18
  catch(PDOException $e){
20
19
  $pdo->rollback();