function views_db_object::init
3.x view.inc | views_db_object::init($init = TRUE) |
2.x view.inc | views_db_object::init($init = TRUE) |
Initialize this object, setting values from schema defaults.
Parameters
$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 - Constructor
- views_display::views_display in includes/
view.inc
File
- includes/
view.inc, line 2159 - Provides the view object type and associated methods.
Class
- views_db_object
- Base class for views' database objects.
Code
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 = '';
}
}
}
}