Backend\Modules\Blog\Engine\Model::existsComment PHP Method

existsComment() public static method

Checks if a comment exists
public static existsComment ( integer $id ) : integer
$id integer The id of the item to check for existence.
return integer
    public static function existsComment($id)
    {
        return (bool) BackendModel::getContainer()->get('database')->getVar('SELECT 1
             FROM blog_comments AS i
             WHERE i.id = ? AND i.language = ?
             LIMIT 1', array((int) $id, BL::getWorkingLanguage()));
    }

Usage Example

Beispiel #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendBlogModel::existsComment($this->id)) {
         parent::execute();
         $this->getData();
         $this->loadForm();
         $this->validateForm();
         $this->parse();
         $this->display();
     } else {
         // no item found, throw an exception, because somebody is f*****g with our URL
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }