Backend\Modules\ContentBlocks\Engine\Model::get PHP Method

get() public static method

Get all data for a given id.
Deprecation: use doctrine instead
public static get ( integer $id ) : array
$id integer The id for the record to get.
return array
    public static function get($id)
    {
        trigger_error('Backend\\Modules\\ContentBlocks\\Engine is deprecated.
             Switch to doctrine instead.', E_USER_DEPRECATED);
        return (array) BackendModel::getContainer()->get('database')->getRecord('SELECT i.*, UNIX_TIMESTAMP(i.created_on) AS created_on, UNIX_TIMESTAMP(i.edited_on) AS edited_on
             FROM content_blocks AS i
             WHERE i.id = ? AND i.status = ? AND i.language = ?
             LIMIT 1', array((int) $id, 'active', BL::getWorkingLanguage()));
    }

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