Created At: 2026-06-14T15:33:10Z
Completed At: 2026-06-14T15:33:10Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4711
Total Bytes: 198658
Showing lines 175 to 205
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
175: try {
176:     // Hubungkan ke SQLite Database
177:     $db = new PDO("sqlite:" . $db_file);
178:     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
179:     $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
180: 
181:     // Self-migrating database schema updates for dynamic graph parameters
182:     $cols_to_add = [
183:         'graph_base_value' => 'REAL DEFAULT NULL',
184:         'graph_uncertainty' => 'REAL DEFAULT NULL',
185:         'graph_ssp1_slope' => 'REAL DEFAULT NULL',
186:         'graph_ssp2_slope' => 'REAL DEFAULT NULL',
187:         'graph_ssp3_slope' => 'REAL DEFAULT NULL',
188:         'graph_ssp5_slope' => 'REAL DEFAULT NULL',
189:         'csv_data' => 'TEXT DEFAULT NULL',
190:         'image_climate_map_url_2' => "TEXT DEFAULT ''"
191:     ];
192:     foreach ($cols_to_add as $col_name => $col_def) {
193:         try {
194:             $db->exec("ALTER TABLE future_climate ADD COLUMN {$col_name} {$col_def}");
195:         } catch (PDOException $ex) {
196:             // Kolom sudah ada, abaikan saja
197:         }
198:     }
199: } catch (PDOException $e) {
200:     header('Content-Type: application/json');
201:     echo json_encode(['error' => 'Gagal terhubung ke database server.']);
202:     exit;
203: }
204: 
205: // Inisialisasi Tabel jika database baru dibuat atau masih kosong
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
