1

Suppose I have this models

  • User.class.php
  • userTable.class.php

I want to create a method to update the user

Action

class userActions extends sfActions {

public function executeUpdateUser(sfWebRequest $request) {
     $user_id = $request->getParameter('id');
     // here i want to call function to update the user 
     // updateUser($id);
}

Where should I put this function updateUser($id) ?

ON user.class.php --> And call it like that User::updateUser($id);

OR ON userTable.class.php --> And call it like that Doctrine_Core::getTable('User')->updateUser($id);

4

1 に答える 1

0

私はこのようにします:

$user = Doctrine_Core::getTable('User')->find($user_id);
$user->updateWithData($data); // ::update() is already an existing method
$user->save();

また

$user = Doctrine_Core::getTable('User')->find($user_id);
$user->updateWithDataAndSave($data);
于 2012-11-08T10:00:13.967 に答える