Doctrine 1
  1. Doctrine 1
  2. DC-942

fromArray makes unnessesary cals to database

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      If I do toArray(true) on record with realtions and later fromArray($array, true) on with same data unnessesary calls to database are made.

      $message = new Message();
      $message->Sender = new User(); // if i leave out this line sender will first get loaded from database and then overwritten with provided data
      $message->Receiver = new User();   // if i leave out this line receiver will first get loaded from database and then overwritten with provided data
      $message->fromArray($data);
      
      

      In Doctrine_Record::fromArray()

      if ($deep && $this->getTable()->hasRelation($key)) {
          if ( ! $this->$key) {                                           --> data gets loaded from db here, refreshRelated is not even executed.
              $this->refreshRelated($key);
          }
      ...
      }
      

      Is this desired behavour? Wouldnt it be smarter to create empty object automaticly instead of loading it from db?
      Also have look at http://trac.doctrine-project.org/ticket/1434

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ivo Võsa
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: