ActiveRecord update howto?

Hi,

i'm using this to create new record:


public function create() {
  $user = PicoraActiveRecord::build('PicoraUser', array(
      'username' => $_POST['username'],
      'password' => $_POST['password'],
      ...
    )   
  );  
  if ($user->save()) {
    self::redirect(array('Users', 'index'));
  }   
}

How to update existing record?

Posted October 14th, 2007 at 2:19pm by vlado

You need to have a PicoraActiveRecord-Instance of your row, you would change. You can geht this by calling $a = PicoraActiveRecord::findByField('PicoraUser', ...). Now you can access all fields by calling it as a property of the instance like $a->username = "new username". After finish changing the properties/fields, you can call a->save() to put the changes back in the Database.

Posted October 17th, 2007 at 3:24am by Aaron

Login or Register to Post