Hello,
I am trying to save a simple record to an sqlite database. Here are the details…
[color="#0000FF"]class StudentAR extends ActiveRecord
{
public $name;
public $age;
public $salary;
public function rules()
{
return [
['name','string'],
[['salary','age'],'integer','message'=>'Must be a valid number'],
[['name','salary','age'],'required'],
];
}
public static function tableName()
{
return 'student';
}
}[/color]
In the controller… i do this…
$st = new StudentAR();
$st->name = $model->name;
$st->age = $model->age;
$st->salary = $model->salary;
$st->validate();
$st->save();
echo $st->name . " – name<br />";
echo $st->age . " – age<br />";
echo $st->salary . " – salary<br />";
my sqlite database table is this
create table student(name text, age integer, salary integer)
every time, i run my code it goes through without any error… but this is what i see in my table.
sqlite> select * from student;
||
||
I dont know why it is inserting only null values.
When i print the actual value in the echo statements, they seem to print the correct values.
what am i missing?
Thanks in advance.