Ignore:
Timestamp:
12/16/11 11:19:54 (13 years ago)
Author:
jkraaijeveld
Message:

Implemented lazy evaluation.

  • Initially, references to other database objects are now given as an ID rather than an object.
  • Every model class now has an evaluate() function, which gets all the objects that object has references to. Returns true if it got all the values correctly, false if there are invalid references.
  • Every connector now first evaluates an object before storing, to make sure only objects with valid references get stored.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/Answer.php

    r157 r186  
    88class Answer extends ResearchToolObject {
    99    public $question;
    10     public $values;
     10        public $values;
    1111   
    1212    /**
     
    2424      $this->question = $question;
    2525      $this->values = $values;
    26     }
     26        }
     27       
     28        /**
     29         * function evaluate()
     30         * Evaluates the references and fills in the objects for them instead.
     31         */
     32        public function evaluate()
     33        {
     34                if(is_string($this->question))
     35                {
     36                        $dbi = new DatabaseInterface();
     37                        $result = $dbi->get("question", array("code" => $this->question));
     38                        if(!isset($result[0]))
     39                                return false;
     40                        $this->question = $result[0];
     41                }
     42                return true;
     43
     44        }
    2745}
    2846
Note: See TracChangeset for help on using the changeset viewer.