Yes, the only question is whether I'm doing it correct or not. And maybe a fix for it.
I have an application in Yii where I have a simple Admin backend where I can put some predefined settings in it.
The MySQL database table:

I have an Admin Controller: I am only showing the intended action
class AdminController extends Controller
{
public function actionIndex()
{
// Update a setting
if (isset($_POST['submit']))
{
AdminSetting::updateSetting('topCategory', $_POST['topCategory']);
AdminSetting::updateSetting('marketRegion', $_POST['marketRegion']);
}
// Get all settings
$topCategory = AdminSetting::model()->find('name = :name', array(':name' => 'topCategory'));
$marketRegion = AdminSetting::model()->find('name = :name', array(':name' => 'marketRegion'));
if (isset($marketRegion->value))
$marketRegion = $marketRegion->value;
if (isset($topCategory->value))
$topCategory = $topCategory->value;
$this->render('index', array('topCategory' => $topCategory, 'marketRegion' => $marketRegion));
}
}
The model AdminSetting.php: I am only showing the added function: updateSetting
class AdminSetting extends CActiveRecord
{
public static function updateSetting($name, $value)
{
Yii::app()->db->createCommand("UPDATE admin_setting SET value = '$value' WHERE name = '$name'")->execute();
}
}
The User Interface:

I have it done this way, because I have one page, with multiple records showing data. That is not the way it default works in Yii. Whereever I search I see only that other programmers are editing one record at a time.
A second question arise: How to save multiple records to the database at a time with the default functionality of the ActiveRecordModel.
I see that if I continue this way, I have a growing list in my actionIndex that saves every field by hand.
Thanks in advance for your help.