Back to Workflow class

Method createAssociation

public bool
createAssociation
(int $pk, int $state)
Creates an association for the workflow_associations table
Parameters
  • int $pk ID of the item
  • int $state ID of state
Returns
  • bool
Since
  • 4.0.0
Class: Workflow
Project: Joomla

Method createAssociation - Source code

/**
 * Creates an association for the workflow_associations table
 *
 * @param   integer  $pk     ID of the item
 * @param   integer  $state  ID of state
 *
 * @return  boolean
 *
 * @since  4.0.0
 */
public function createAssociation(int $pk, int $state) : bool
{
    try {
        $query = $this->db->getQuery(true);
        $query->insert($this->db->quoteName('#__workflow_associations'))->columns([$this->db->quoteName('item_id'), $this->db->quoteName('stage_id'), $this->db->quoteName('extension')])->values(':pk, :state, :extension')->bind(':pk', $pk, ParameterType::INTEGER)->bind(':state', $state, ParameterType::INTEGER)->bind(':extension', $this->extension);
        $this->db->setQuery($query)->execute();
    } catch (\Exception $e) {
        return false;
    }
    return true;
}