Backend\Modules\Tags\Engine\Model::delete PHP Method

delete() public static method

Delete one or more tags.
public static delete ( mixed $ids )
$ids mixed The ids to delete.
    public static function delete($ids)
    {
        // get db
        $db = BackendModel::getContainer()->get('database');
        // make sure $ids is an array
        $ids = (array) $ids;
        // delete tags
        $db->delete('tags', 'id IN (' . implode(',', $ids) . ')');
        $db->delete('modules_tags', 'tag_id IN (' . implode(',', $ids) . ')');
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('delete'), 'delete');
     // no id's provided
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-selection');
     } else {
         // at least one id
         // redefine id's
         $aIds = (array) $_GET['id'];
         // delete comment(s)
         if ($action == 'delete') {
             BackendTagsModel::delete($aIds);
         }
     }
     // redirect
     $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted');
 }