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

delete() public static method

Delete a question
public static delete ( integer $id )
$id integer
    public static function delete($id)
    {
        $question = self::get($id);
        /** @var $db \SpoonDatabase */
        $db = BackendModel::getContainer()->get('database');
        $db->delete('faq_questions', 'id = ?', array((int) $id));
        $db->delete('meta', 'id = ?', array((int) $question['meta_id']));
        BackendTagsModel::saveTags($id, '', 'Faq');
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     if ($this->id !== null && BackendFaqModel::exists($this->id)) {
         parent::execute();
         $this->record = BackendFaqModel::get($this->id);
         // delete item
         BackendFaqModel::delete($this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('item' => $this->record));
         $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted&var=' . rawurlencode($this->record['question']));
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }