Answer the question
In order to leave comments, you need to log in
Simple form processing?
Good day to all. I'm just starting to learn the Yii1 framework, and I'm stuck on a seemingly trivial thing. HEEEEELP!
There is the most common Index.php model (Generated in gii):
<?php
class Index extends CActiveRecord
{
public function tableName()
{
return 'tbl_index';
}
public function rules()
{
return array(
array('title, content, create_time', 'required'),
array('create_time', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>128),
array('id, title, content, create_time', 'safe', 'on'=>'search'),
);
}
public function relations()
{
return array(
);
}
public function attributeLabels()
{
return array(
'id' => 'ID',
'title' => 'Title',
'content' => 'Content',
'create_time' => 'Create Time',
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('title',$this->title,true);
$criteria->compare('content',$this->content,true);
$criteria->compare('create_time',$this->create_time);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
<?php
class IndexController extends Controller{
public function actionIndex()
{
$index = new index();
$index->title='тестовая запись';
$index->content='содержимое записи';
$index->save();
//$this->render('index',array('model'=>$index));
}
}
Answer the question
In order to leave comments, you need to log in
$index = newindex (); - $index = newIndex ();. parentheses are optional
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question