Back to Workflow class

Method updateAssociations

public bool
updateAssociations
(array $pks, int $state)
Update an existing association with a new state
Parameters
  • array $pks An Array of item IDs which should be changed
  • int $state The new state ID
Returns
  • bool
Since
  • 4.0.0
Class: Workflow
Project: Joomla

Method updateAssociations - Source code

/**
 * Update an existing association with a new state
 *
 * @param   array    $pks    An Array of item IDs which should be changed
 * @param   integer  $state  The new state ID
 *
 * @return  boolean
 *
 * @since  4.0.0
 */
public function updateAssociations(array $pks, int $state) : bool
{
    $pks = ArrayHelper::toInteger($pks);
    try {
        $query = $this->db->getQuery(true);
        $query->update($this->db->quoteName('#__workflow_associations'))->set($this->db->quoteName('stage_id') . ' = :state')->whereIn($this->db->quoteName('item_id'), $pks)->where($this->db->quoteName('extension') . ' = :extension')->bind(':state', $state, ParameterType::INTEGER)->bind(':extension', $this->extension);
        $this->db->setQuery($query)->execute();
    } catch (\Exception $e) {
        return false;
    }
    return true;
}