I'm trying to update the user details table using php activerecord but everytime I get this error
::save() cannot be invoked because this model is set to read only
I can insert to the same table but I can't update
Details.php
<?php
class Details extends ActiveRecord\Model
{
public static $table_name='details';
public static $primary_key='id_user_detail';
public function before_create()
{
$this->date_created = date("Y-m-d H:i:s");
$this->date_modified = date("Y-m-d H:i:s");
}
public function before_update()
{
$this->date_modified = date("Y-m-d H:i:s");
}
}?>
profile-edit.php
$sql = " select * from details where id_user_detail=1";
$user = Details::find_by_sql($sql);
$user->user_fname="test";
$user->save();
How can I do an update?
You probably trying to change class attributes before you have instantiate the class.
Details::find_by_sql() should return a new Details instance. For Example :