示例#1
0
 function __construct($table, $info, $auto = array())
 {
     $this->info = $info;
     $this->table = db()->t($table);
     $this->auto = $auto;
     foreach ($this->info as $cat => $opts) {
         if (isset($this->{$cat})) {
             throw new Exception('Invalid Category Name');
         }
         $this->{$cat} = new stdClass();
         foreach ($opts['items'] as $id => $option) {
             $this->{$cat}->{$id} = $option['value'];
         }
     }
     if ($auto) {
         $query = array();
         foreach ($auto as $k => $v) {
             $query[] = db()->format("`%s` = '%s'", $k, $v);
         }
         $res = $this->table->get(implode(' AND ', $query));
     } else {
         $res = $this->table->all();
     }
     foreach ($res as $value) {
         if (isset($this->{$value['category']}->{$value['name']})) {
             $this->{$value['category']}->{$value['name']} = $value['value'];
         }
     }
 }
示例#2
0
 public function get_edit($id)
 {
     $cond = $this->condition . db()->format(" AND `{$this->pk}` = %d LIMIT 1", $id);
     if (!$this->edit) {
         throw new Exception('Bearbeiten nicht möglich!');
     }
     if (!($edit = $this->table->get($cond)->assoc())) {
         throw new Exception('Datensatz nicht gefunden!');
     }
     return $this->create_form('edit', $this->link('update', $edit[$this->pk]), $edit, $this->link->pure());
 }