You are here

protected function DBObject::load in Entity Construction Kit (ECK) 7.3

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

Load.

Parameters

string $property: The property we will use to search for the record.

mixed $value: the value the property should match.

File

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

Class

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

Code

protected function load($property, $value) {
  $result = db_select($this->table, 't')
    ->fields('t')
    ->condition($property, $value, '=')
    ->execute()
    ->fetchAssoc();
  if ($result) {
    foreach ($result as $property => $value) {
      if (in_array($property, $this->serialize)) {
        $value = drupal_json_decode($value);
      }
      $this->{$property} = $value;
    }

    // We should only set the is_new flag as false if we loaded something.
    $this->is_new = FALSE;
  }
}