if ($v === false or $v === null) {
if (isset($this->fields[$k])) unset($this->fields[$k]);
#if (isset($this->extras[$k])) unset($this->extras[$k]);
- $this->_rows_fields = true;
+ $this->_add_extras = true;
continue;
}
$select_count = ( $where ? $this->db()->conf_type('select_count') : null );
if (empty($select_count)) $select_count = ['',''];
- if (!empty($this->_rows_fields)) {
+ if (!empty($this->_add_extras)) {
foreach ($this->fields() as $f) {
if (empty($f->extra)) $select_fields[] = $f->sql_name();
}
}
//
- // Fields filter
+ // Fields filter / Add missing
//
- $this->fields_only($row,array_keys($opt['fields']));
+ $new = [];
+ foreach ($opt['fields'] as $k=>$f) {
+ $new[$k] = isset($row[$k]) ? $row[$k] : null;
+ }
+ $row = $new;
//
// Format
}
+ //
+ // Keep only wanted fields
+ //
+ $this->fields_only($row);
+
//
// Post
//
$this->db()->type = $opt['db_type_from'];
}
- #
- # Fields
- #
- $opt['fields'] = $fields = $this->fields();
- $this->fields_only($fields);
-
#
# Build query
#
} # < nosql
+ #
+ # Fields
+ #
+ $opt['fields'] = $fields = $this->fields();
+# NB 07.02.18 $this->fields_only($fields);
+
# Check fields_only exists
if (!empty($this->fields_only)) foreach ($this->fields_only as $f) {
if (!$this->field($f)) $this->bye("Unknown field ".$f);
if ($this->buttons() and !empty($buttons[0])) $html .= '<td class="action">'.$buttons[0].'</td>'.NB_EOL;
foreach ($row as $k => $v) {
- if ( !empty($this) and !empty($this->field($k)) ) {
+ if ( !empty($this->field($k)) ) {
$v = $this->field($k)->htmlValue($v);
}
$html .= '<td'.$this->__rows_table_attr[$k].'>'.$v.'</td>'.NB_EOL;