I have a sensor list form in my program. There the user can do CRUD. How do when the user enters new sensor data, the new data automatically creates a new column in the table in my database (automatically alter table)
public function store(Request $request){
$data = new Mst_sensor();
$arr = array_merge($arr, ['created_by' => Auth::user()->userid, 'created_at' => date('Y-m-d H:i:s')]);
$data->create($arr);
$sensor= new Trs_sensor_d;
$table = $sensor->getTable();
$columns = \DB::getSchemaBuilder()->getColumnListing($table);
$data_field = [];
foreach ($columns as $k => $v) {
$data_field[$k] = $v;
}
$removed = array_pop($data_field);
$fix_data_field = end($data_field);
$q = "ALTER TABLE `trs_raw_d_gpa` ADD `coba` VARCHAR(25) NULL AFTER '" . $fix_data_field . "'";
}
How can alter table run automatically???
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire