You are here

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

Same name and namespace in other branches
  1. 7.3 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 130
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 isNew flag as false if we loaded something.
    $this->isNew = FALSE;
  }
}