Code Duplication    Length = 33-39 lines in 2 locations

src/cli/Database/Base/Instance.php 1 location

@@ 489-527 (lines=39) @@
486
     * @return void
487
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
488
     */
489
    public function reload($deep = false, ConnectionInterface $con = null)
490
    {
491
        if ($this->isDeleted()) {
492
            throw new PropelException("Cannot reload a deleted object.");
493
        }
494
495
        if ($this->isNew()) {
496
            throw new PropelException("Cannot reload an unsaved object.");
497
        }
498
499
        if ($con === null) {
500
            $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME);
501
        }
502
503
        // We don't need to alter the object instance pool; we're just modifying this instance
504
        // already in the pool.
505
506
        $dataFetcher = ChildInstanceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
507
        $row = $dataFetcher->fetch();
508
        $dataFetcher->close();
509
        if (!$row) {
510
            throw new PropelException('Cannot find matching row in the database to reload object values.');
511
        }
512
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
513
514
        if ($deep) {  // also de-associate any related objects?
515
516
            $this->collUsers = null;
517
518
            $this->collConnections = null;
519
520
            $this->collInputs = null;
521
522
            $this->collChannels = null;
523
524
            $this->collSubscriptions = null;
525
526
        } // if (deep)
527
    }
528
529
    /**
530
     * Removes this object from datastore and sets delete attribute.

src/cli/Database/Base/Subscription.php 1 location

@@ 850-882 (lines=33) @@
847
     * @return void
848
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
849
     */
850
    public function reload($deep = false, ConnectionInterface $con = null)
851
    {
852
        if ($this->isDeleted()) {
853
            throw new PropelException("Cannot reload a deleted object.");
854
        }
855
856
        if ($this->isNew()) {
857
            throw new PropelException("Cannot reload an unsaved object.");
858
        }
859
860
        if ($con === null) {
861
            $con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME);
862
        }
863
864
        // We don't need to alter the object instance pool; we're just modifying this instance
865
        // already in the pool.
866
867
        $dataFetcher = ChildSubscriptionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
868
        $row = $dataFetcher->fetch();
869
        $dataFetcher->close();
870
        if (!$row) {
871
            throw new PropelException('Cannot find matching row in the database to reload object values.');
872
        }
873
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
874
875
        if ($deep) {  // also de-associate any related objects?
876
877
            $this->aInstance = null;
878
            $this->aInput = null;
879
            $this->aUser = null;
880
            $this->aChannel = null;
881
        } // if (deep)
882
    }
883
884
    /**
885
     * Removes this object from datastore and sets delete attribute.