public function actionCreate($tb) { $model = new DefineTableField(); $model->table = $tb; if ($model->load($_POST) && $model->save()) { $fieldName = $model->name_en; $dataType = $model->getFieldType(); $isNull = $model->is_null; $sql = SqlData::getAddFieldSql($tb, $fieldName, $dataType, $isNull); LuLu::execute($sql); CacheUtility::createFieldCache(); return $this->redirect(['index', 'tb' => $tb]); } else { $locals = []; $locals['table'] = $tb; $locals['model'] = $model; return $this->render('create', $locals); } }
public function actionDelete($tb) { $model = $this->findModel($tb); $model->delete(); DefineTableField::deleteAll(['table' => $tb]); $sql = SqlData::getDropTableSql($tb); LuLu::execute($sql); CacheUtility::createTableCache(); CacheUtility::createFieldCache(); return $this->redirect(['index']); }
protected function updateViews($id) { $sql = 'update ' . $this->currentTableName . ' set views=views+1 where id=' . $id; LuLu::execute($sql); }