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

exists() public static method

Does the question exist?
public static exists ( integer $id ) : boolean
$id integer
return boolean
    public static function exists($id)
    {
        return (bool) BackendModel::getContainer()->get('database')->getVar('SELECT 1
             FROM faq_questions AS i
             WHERE i.id = ? AND i.language = ?
             LIMIT 1', array((int) $id, BL::getWorkingLanguage()));
    }

Usage 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');
     }
 }
All Usage Examples Of Backend\Modules\Faq\Engine\Model::exists