You are here

protected function DBObject::__construct in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.classes.inc \DBObject::__construct()

Constructor.

2 calls to DBObject::__construct()
Bundle::__construct in ./eck.classes.inc
Constructor.
EntityType::__construct in ./eck.classes.inc
Constructor.
2 methods override DBObject::__construct()
Bundle::__construct in ./eck.classes.inc
Constructor.
EntityType::__construct in ./eck.classes.inc
Constructor.

File

./eck.classes.inc, line 26
Classes for all the different objects used in ECK.

Class

DBObject
@file Classes for all the different objects used in ECK.

Code

protected function __construct($table) {
  $this->serialize = array();
  $this->isNew = TRUE;

  // Iterator variable.
  $this->position = 0;

  // Is this a real table? If it is, check it.
  if ($schema = drupal_get_schema($table)) {
    $this->table = $table;
    $this->primaryKeys = $schema["primary key"];
    $this->vars = array_keys($schema['fields']);

    // Do we want to handle searialized variables by default? let's do it
    // and wait for some critizism.
    foreach ($schema['fields'] as $name => $field) {
      if (array_key_exists('serialize', $field) && $field['serialize']) {
        $this->serialize[] = $name;
      }
    }
    foreach ($this->vars as $var) {
      if ($schema['fields'][$var]['type'] != "serial") {
        $this->data[$var] = NULL;
      }
    }
  }
  else {

    // @todo throw an exception.
  }
}