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

existsData() public static method

Does the data item exist.
public static existsData ( integer $id ) : boolean
$id integer Id of the data item.
return boolean
    public static function existsData($id)
    {
        return (bool) BackendModel::getContainer()->get('database')->getVar('SELECT 1
             FROM forms_data AS fd
             WHERE fd.id = ?
             LIMIT 1', (int) $id);
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendFormBuilderModel::existsData($this->id)) {
         parent::execute();
         $this->setFilter();
         $this->getData();
         $this->parse();
         $this->display();
     } else {
         // no item found, redirect with an error, because somebody is f*****g with our url
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }