function views_db_object::init
Initialize this object, setting values from schema defaults.
Parameters
array|bool $init: If an array, this is a set of values from db_fetch_object to load. Otherwse, if TRUE values will be filled in from schema defaults.
2 calls to views_db_object::init()
- view::__construct in includes/
view.inc - Standard PHP constructor.
- views_display::__construct in includes/
view.inc
File
-
includes/
view.inc, line 2250
Class
- views_db_object
- Base class for views' database objects.
Code
public function init($init = TRUE) {
if (is_array($init)) {
return $this->load_row($init);
}
if (!$init) {
return;
}
$schema = drupal_get_schema($this->db_table);
if (!$schema) {
return;
}
// Go through our schema and build correlations.
foreach ($schema['fields'] as $field => $info) {
if ($info['type'] == 'serial') {
$this->{$field} = NULL;
}
if (!isset($this->{$field})) {
if (!empty($info['serialize']) && isset($info['serialized default'])) {
$this->{$field} = unserialize($info['serialized default']);
}
elseif (isset($info['default'])) {
$this->{$field} = $info['default'];
}
else {
$this->{$field} = '';
}
}
}
}