Code Duplication    Length = 32-37 lines in 3 locations

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

@@ 474-510 (lines=37) @@
471
     * @return void
472
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
473
     */
474
    public function reload($deep = false, ConnectionInterface $con = null)
475
    {
476
        if ($this->isDeleted()) {
477
            throw new PropelException("Cannot reload a deleted object.");
478
        }
479
480
        if ($this->isNew()) {
481
            throw new PropelException("Cannot reload an unsaved object.");
482
        }
483
484
        if ($con === null) {
485
            $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME);
486
        }
487
488
        // We don't need to alter the object instance pool; we're just modifying this instance
489
        // already in the pool.
490
491
        $dataFetcher = ChildInstanceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
492
        $row = $dataFetcher->fetch();
493
        $dataFetcher->close();
494
        if (!$row) {
495
            throw new PropelException('Cannot find matching row in the database to reload object values.');
496
        }
497
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
498
499
        if ($deep) {  // also de-associate any related objects?
500
501
            $this->collUsers = null;
502
503
            $this->collConnections = null;
504
505
            $this->collChannels = null;
506
507
            $this->collSubscriptions = null;
508
509
        } // if (deep)
510
    }
511
512
    /**
513
     * Removes this object from datastore and sets delete attribute.

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

@@ 796-827 (lines=32) @@
793
     * @return void
794
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
795
     */
796
    public function reload($deep = false, ConnectionInterface $con = null)
797
    {
798
        if ($this->isDeleted()) {
799
            throw new PropelException("Cannot reload a deleted object.");
800
        }
801
802
        if ($this->isNew()) {
803
            throw new PropelException("Cannot reload an unsaved object.");
804
        }
805
806
        if ($con === null) {
807
            $con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME);
808
        }
809
810
        // We don't need to alter the object instance pool; we're just modifying this instance
811
        // already in the pool.
812
813
        $dataFetcher = ChildSubscriptionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
814
        $row = $dataFetcher->fetch();
815
        $dataFetcher->close();
816
        if (!$row) {
817
            throw new PropelException('Cannot find matching row in the database to reload object values.');
818
        }
819
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
820
821
        if ($deep) {  // also de-associate any related objects?
822
823
            $this->aInstance = null;
824
            $this->aUser = null;
825
            $this->aChannel = null;
826
        } // if (deep)
827
    }
828
829
    /**
830
     * Removes this object from datastore and sets delete attribute.

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

@@ 538-571 (lines=34) @@
535
     * @return void
536
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
537
     */
538
    public function reload($deep = false, ConnectionInterface $con = null)
539
    {
540
        if ($this->isDeleted()) {
541
            throw new PropelException("Cannot reload a deleted object.");
542
        }
543
544
        if ($this->isNew()) {
545
            throw new PropelException("Cannot reload an unsaved object.");
546
        }
547
548
        if ($con === null) {
549
            $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME);
550
        }
551
552
        // We don't need to alter the object instance pool; we're just modifying this instance
553
        // already in the pool.
554
555
        $dataFetcher = ChildUserQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
556
        $row = $dataFetcher->fetch();
557
        $dataFetcher->close();
558
        if (!$row) {
559
            throw new PropelException('Cannot find matching row in the database to reload object values.');
560
        }
561
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
562
563
        if ($deep) {  // also de-associate any related objects?
564
565
            $this->aInstance = null;
566
            $this->collConnections = null;
567
568
            $this->collSubscriptions = null;
569
570
        } // if (deep)
571
    }
572
573
    /**
574
     * Removes this object from datastore and sets delete attribute.