11.3.4 CRUD operations: UPDATE

The UPDATE operation is simply a call to the update() method:

/**
 * Update Entity into DB
 * @param mixed $id primary key(s)
 * @param array|object $data new Entity data, or Entity object
 * @param bool|string $validate TRUE to validate all, a named @orm-validate-subset, or FALSE to skip validation
 * @param int $fetchMode fetch mode (FETCH_OBJ, FETCH_ARRAY, FETCH_RAW), FALSE to skip fetch after insert
 * @param string|null $fetchSubset optional fetch subset as defined in @orm-subset
 * @return mixed $Entity object or array if $fetchMode, TRUE if not $fetchMode, FALSE on failure
 * @throws Exception
 */
function update($id, $data=[], $validate=true, $fetchMode=self::FETCH_OBJ, $fetchSubset=null)

Example:

// pass new values array
$UsersRepository->update(34, ['name'=>'Jack']

// 1 - change Entity directly
$User34 = $UsersRepository->fetch(34);
$User->age = 28;
$UserRepository->update($User34);