Ejemplo n.º 1
0
 /**
  * Retrieve controls value from post, or from database if is readony
  */
 protected function retrieveControls()
 {
     if (!$this->primaryKeyValue || !count($this->readOnlyDbControls)) {
         return parent::retrieveControls();
     }
     foreach ($this->controls as $control) {
         if (!in_array($control, $this->readOnlyDbControls, true)) {
             $control->retrieveValue();
         }
     }
     //load readonly controls
     $fields = array();
     foreach ($this->readOnlyDbControls as $name => $control) {
         $fields[] = $this->db->quoteIdentifier($control->getDbField()) . ' AS ' . $name;
     }
     //there not db fields. Hm.... Special case.
     if (!count($fields)) {
         return;
     }
     $selectSQL = "SELECT " . implode(", ", $fields) . " from " . $this->db->quoteIdentifier($this->tableName) . "  where " . $this->db->quoteIdentifier($this->primaryKeyName) . " = ?";
     $row = $this->db->fetchRow($selectSQL, $this->primaryKeyValue);
     if (!$row) {
         $this->errors[] = $this->localizer->getMessage("Database Error: Cannot find specified row");
     } else {
         foreach ($this->readOnlyDbcontrols as $name => $control) {
             $control->setDbValue($row[$name]);
         }
     }
 }