Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2302

entity not updating with existing \Datetime object

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: 2.1.7
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      ubuntu 12.04
      PHP 5.3.10
      PostgreSQL 8.4
      Symfony 2.0.15

      Description

      Within an entity i have an method to add days to a subscription. For that an datetime object is modified.

      But the database is not going to be updated if an already existing datetime-object is modified an set. It's only working when an freshly created datetime object is used.

      NOT WORKING EXAMPLE:

          public function addDaysToSubscription($days) {
      
              if ($this->hasValidSubscription()) {
      
                  $startFromDate = $this->getSubscriptionValidUntil();
              }
              else {
      
                  $startFromDate = new \DateTime('now');
              }
      
              $this->setSubscriptionValidUntil($startFromDate->modify('+' . $days .' days'));
          }
      

      WORKAROUND:

          public function addDaysToSubscription($days) {
      
              if ($this->hasValidSubscription()) {
      
                  $validDate = $this->getSubscriptionValidUntil()->format('Y-m-d H:i:s');
                  $startFromDate = new \DateTime($validDate);
              }
              else {
      
                  $startFromDate = new \DateTime('now');
              }
      
              $this->setSubscriptionValidUntil($startFromDate->modify('+' . $days .' days'));
          }
      

        Activity

        Stephan Tijink created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Benjamin Eberlei made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Stephan Tijink
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: