Backend\Modules\FormBuilder\Engine\Model::deleteData PHP Method

deleteData() public static method

Deletes one or more data items.
public static deleteData ( array $ids )
$ids array Ids of data items.
    public static function deleteData(array $ids)
    {
        $db = BackendModel::getContainer()->get('database');
        $db->delete('forms_data', 'id IN(' . implode(',', $ids) . ')');
        $db->delete('forms_data_fields', 'data_id IN(' . implode(',', $ids) . ')');
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('delete'), '');
     // form id
     $formId = \SpoonFilter::getGetValue('form_id', null, '', 'int');
     // no id's provided
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-items-selected');
     } elseif ($action == '') {
         // no action provided
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=no-action-selected');
     } elseif (!BackendFormBuilderModel::exists($formId)) {
         // valid form id
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     } else {
         // redefine id's
         $ids = (array) $_GET['id'];
         // delete comment(s)
         if ($action == 'delete') {
             BackendFormBuilderModel::deleteData($ids);
         }
         // define report
         $report = count($ids) > 1 ? 'items-' : 'item-';
         // init var
         if ($action == 'delete') {
             $report .= 'deleted';
         }
         // redirect
         $this->redirect(BackendModel::createURLForAction('Data') . '&id=' . $formId . '&report=' . $report);
     }
 }
All Usage Examples Of Backend\Modules\FormBuilder\Engine\Model::deleteData