exists() public static method

Does the item exist.
Deprecation: use doctrine instead
public static exists ( integer $id, boolean $activeOnly = true ) : boolean
$id integer The id of the record to check for existence.
$activeOnly boolean Only check in active items?
return boolean
示例#1
0
文件: Edit.php 项目: bwgraves/forkcms
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendContentBlocksModel::exists($this->id)) {
         parent::execute();
         $this->getData();
         $this->loadRevisions();
         $this->loadForm();
         $this->validateForm();
         $this->parse();
         $this->display();
     } else {
         // no item found, throw an exceptions, because somebody is f*****g with our url
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
示例#2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendContentBlocksModel::exists($this->id)) {
         parent::execute();
         $this->record = (array) BackendContentBlocksModel::get($this->id);
         // delete item
         BackendContentBlocksModel::delete($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // item was deleted, so redirect
         $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted&var=' . urlencode($this->record['title']));
     } else {
         // no item found, redirect to the overview with an error
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }