質問編集履歴

1

少し追記しました。

2019/10/28 06:32

投稿

awazon78
awazon78

スコア32

test CHANGED
File without changes
test CHANGED
@@ -1,10 +1,10 @@
1
1
  ```sql
2
2
 
3
- INSERT INTO A
3
+ INSERT INTO TABLE_A
4
4
 
5
5
  SELECT *
6
6
 
7
- FROM B
7
+ FROM TABLE_B
8
8
 
9
9
  where date > 0
10
10
 
@@ -26,9 +26,9 @@
26
26
 
27
27
  $this->db->select('*');
28
28
 
29
- $this->db->insert('point_history_bk',$date);
29
+ $this->db->insert('TABLE_A',$date);
30
30
 
31
- $this->db->from('point_history_temp');
31
+ $this->db->from('TABLE_B');
32
32
 
33
33
  $this->db->where($where);
34
34
 
@@ -47,3 +47,49 @@
47
47
  ```
48
48
 
49
49
  どのように記述したらcodeigniterで実行できるでしょうか・
50
+
51
+
52
+
53
+ -------------------------以下 10/28 15:28追記
54
+
55
+ 趣旨から違う為書きませんでしたが、本来やりたい事は以下になります。
56
+
57
+ TABLE_AからTABLE_Bへインサート
58
+
59
+ インサートした物はDELETEです。
60
+
61
+
62
+
63
+ ```
64
+
65
+ $time_start = microtime(true);
66
+
67
+ $where = [
68
+
69
+ 'date >' => 0,
70
+
71
+ ];
72
+
73
+ $this->db->order_by('id', 'DESC');
74
+
75
+ $this->db->limit(100000);
76
+
77
+ $records = $this->db->get('TABLE_A')->result_array();
78
+
79
+
80
+
81
+
82
+
83
+ foreach ($records as $key =>$record) {
84
+
85
+ $this->db->insert('TABLE_B', $record);
86
+
87
+ $this->db->delete('TABLE_A', ['id' => $record['id']]);
88
+
89
+ }
90
+
91
+ ```
92
+
93
+
94
+
95
+ しかしこれだとなかなか遅い。。。