protected function _init_fields() { if (count($this->_db_fields)) { return; } $this->_init_table(); $cols = SDB::get_table_columns($this->_db_table); foreach (get_object_vars($this) as $prop => $val) { if ($prop[0] == '_' || $prop == $this->_db_key || is_array($val) || is_object($val) || $val === null) { continue; } if (!array_key_exists($prop, $cols)) { throw new Exception("Table '{$this->_db_table}' doesn't have field '{$prop}'"); } $this->map_field($prop, $prop, $cols[$prop]['t'], $cols[$prop]['s']); } // map _db_key here, because get_object_vars not returns virtual properties $this->map_field($this->_db_key, $this->_db_key, $cols[$this->_db_key]['t'], $cols[$this->_db_key]['s']); }