get() public static méthode

Fetch a record from the database
public static get ( integer $id ) : array
$id integer The id of the record to fetch.
Résultat array
Exemple #1
0
 /**
  * Get the data
  */
 private function loadData()
 {
     $this->record = (array) BackendLocationModel::get($this->id);
     // no item found, throw an exceptions, because somebody is f*****g with our URL
     if (empty($this->record)) {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
     $this->settings = BackendLocationModel::getMapSettings($this->id);
     // load the settings from the general settings
     if (empty($this->settings)) {
         $settings = $this->get('fork.settings')->getForModule('Location');
         $this->settings['width'] = $settings['width_widget'];
         $this->settings['height'] = $settings['height_widget'];
         $this->settings['map_type'] = $settings['map_type_widget'];
         $this->settings['map_style'] = isset($settings['map_style_widget']) ? $settings['map_style_widget'] : 'standard';
         $this->settings['zoom_level'] = $settings['zoom_level_widget'];
         $this->settings['center']['lat'] = $this->record['lat'];
         $this->settings['center']['lng'] = $this->record['lng'];
     }
     // no center point given yet, use the first occurrence
     if (!isset($this->settings['center'])) {
         $this->settings['center']['lat'] = $this->record['lat'];
         $this->settings['center']['lng'] = $this->record['lng'];
     }
     $this->settings['full_url'] = isset($this->settings['full_url']) ? $this->settings['full_url'] : false;
     $this->settings['directions'] = isset($this->settings['directions']) ? $this->settings['directions'] : false;
 }
Exemple #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendLocationModel::exists($this->id)) {
         parent::execute();
         // get all data for the item we want to edit
         $this->record = (array) BackendLocationModel::get($this->id);
         // delete item
         BackendLocationModel::delete($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // user was deleted, so redirect
         $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted&var=' . urlencode($this->record['title']));
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }