Back to UCMContent class

Method delete

public bool
delete
(mixed $pk, \Joomla\CMS\UCM\UCMType $type = null)
Delete content from the Core Content table
Parameters
  • mixed $pk Array or comma-separated string of ids to delete
  • \Joomla\CMS\UCM\UCMType $type The content type object
Returns
  • bool True if success
Since
  • 3.1
Class: UCMContent
Project: Joomla

Method delete - Source code

/**
 * Delete content from the Core Content table
 *
 * @param   mixed    $pk    Array or comma-separated string of ids to delete
 * @param   UCMType  $type  The content type object
 *
 * @return  boolean  True if success
 *
 * @since   3.1
 */
public function delete($pk, UCMType $type = null)
{
    $db = Factory::getDbo();
    $type = $type ?: $this->type;
    if (!\is_array($pk)) {
        $pk = explode(',', $pk);
    }
    $query = $db->getQuery(true)->delete($db->quoteName('#__ucm_content'))->where($db->quoteName('core_type_id') . ' = :typeId')->whereIn($db->quoteName('core_content_item_id'), $pk)->bind(':typeId', $type->type_id, ParameterType::INTEGER);
    $db->setQuery($query);
    $db->execute();
    return true;
}