コード例 #1
0
 /**
  * The returned array will contain objects of the default type or
  * objects that inherit from the default.
  *
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function populateObjects(PDOStatement $stmt)
 {
     $results = array();
     // set the class once to avoid overhead in the loop
     $cls = UserPeer::getOMClass(false);
     // populate the object(s)
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key = UserPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj = UserPeer::getInstanceFromPool($key))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj->hydrate($row, 0, true); // rehydrate
             $results[] = $obj;
         } else {
             $obj = new $cls();
             $obj->hydrate($row);
             $results[] = $obj;
             UserPeer::addInstanceToPool($obj, $key);
         }
         // if key exists
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #2
0
ファイル: BaseUserQuery.php プロジェクト: eddypre/Quirofano
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return   User A model object, or null if the key is not found
  * @throws   PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `NOMBRE`, `PASS`, `TIPO`, `ID` FROM `hc_usuarios` WHERE `ID` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new User();
         $obj->hydrate($row);
         UserPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #3
0
ファイル: BaseUser.php プロジェクト: raulito1500/mdokeos
 /**
  * Persists this object to the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All modified related objects will also be persisted in the doSave()
  * method.  This method wraps all precipitate database operations in a
  * single transaction.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        doSave()
  */
 public function save(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("You cannot save an object that has been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     $isInsert = $this->isNew();
     try {
         $ret = $this->preSave($con);
         if ($isInsert) {
             $ret = $ret && $this->preInsert($con);
         } else {
             $ret = $ret && $this->preUpdate($con);
         }
         if ($ret) {
             $affectedRows = $this->doSave($con);
             if ($isInsert) {
                 $this->postInsert($con);
             } else {
                 $this->postUpdate($con);
             }
             $this->postSave($con);
             UserPeer::addInstanceToPool($this);
         } else {
             $affectedRows = 0;
         }
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #4
0
 /**
  * Selects a collection of Subscriber objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Subscriber objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(SubscriberPeer::DATABASE_NAME);
     }
     SubscriberPeer::addSelectColumns($criteria);
     $startcol2 = SubscriberPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + UserPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(SubscriberPeer::CREATED_BY, UserPeer::ID, $join_behavior);
     $criteria->addJoin(SubscriberPeer::UPDATED_BY, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = SubscriberPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = SubscriberPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = SubscriberPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             SubscriberPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Subscriber) to the collection in $obj2 (User)
             $obj2->addSubscriberRelatedByCreatedBy($obj1);
         }
         // if joined row not null
         // Add objects for joined User rows
         $key3 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = UserPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = UserPeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 UserPeer::addInstanceToPool($obj3, $key3);
             }
             // if obj3 loaded
             // Add the $obj1 (Subscriber) to the collection in $obj3 (User)
             $obj3->addSubscriberRelatedByUpdatedBy($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #5
0
ファイル: BaseUser.php プロジェクト: rapila/cms-base
 /**
  * Persists this object to the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All modified related objects will also be persisted in the doSave()
  * method.  This method wraps all precipitate database operations in a
  * single transaction.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @throws Exception
  * @see        doSave()
  */
 public function save(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("You cannot save an object that has been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     $isInsert = $this->isNew();
     try {
         $ret = $this->preSave($con);
         if ($isInsert) {
             $ret = $ret && $this->preInsert($con);
             // denyable behavior
             if (!(UserPeer::isIgnoringRights() || $this->mayOperate("insert"))) {
                 throw new PropelException(new NotPermittedException("insert.by_role", array("role_key" => "users")));
             }
             // extended_timestampable behavior
             if (!$this->isColumnModified(UserPeer::CREATED_AT)) {
                 $this->setCreatedAt(time());
             }
             if (!$this->isColumnModified(UserPeer::UPDATED_AT)) {
                 $this->setUpdatedAt(time());
             }
             // attributable behavior
             if (Session::getSession()->isAuthenticated()) {
                 if (!$this->isColumnModified(UserPeer::CREATED_BY)) {
                     $this->setCreatedBy(Session::getSession()->getUser()->getId());
                 }
                 if (!$this->isColumnModified(UserPeer::UPDATED_BY)) {
                     $this->setUpdatedBy(Session::getSession()->getUser()->getId());
                 }
             }
         } else {
             $ret = $ret && $this->preUpdate($con);
             // denyable behavior
             if (!(UserPeer::isIgnoringRights() || $this->mayOperate("update"))) {
                 throw new PropelException(new NotPermittedException("update.by_role", array("role_key" => "users")));
             }
             // extended_timestampable behavior
             if ($this->isModified() && !$this->isColumnModified(UserPeer::UPDATED_AT)) {
                 $this->setUpdatedAt(time());
             }
             // attributable behavior
             if (Session::getSession()->isAuthenticated()) {
                 if ($this->isModified() && !$this->isColumnModified(UserPeer::UPDATED_BY)) {
                     $this->setUpdatedBy(Session::getSession()->getUser()->getId());
                 }
             }
         }
         if ($ret) {
             $affectedRows = $this->doSave($con);
             if ($isInsert) {
                 $this->postInsert($con);
             } else {
                 $this->postUpdate($con);
             }
             $this->postSave($con);
             UserPeer::addInstanceToPool($this);
         } else {
             $affectedRows = 0;
         }
         $con->commit();
         return $affectedRows;
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #6
0
ファイル: BaseUser.php プロジェクト: lejacome/hospital-mgt
 /**
  * Persists this object to the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All modified related objects will also be persisted in the doSave()
  * method.  This method wraps all precipitate database operations in a
  * single transaction.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        doSave()
  */
 public function save(PropelPDO $con = null)
 {
     foreach (sfMixer::getCallables('BaseUser:save:pre') as $callable) {
         $affectedRows = call_user_func($callable, $this, $con);
         if (is_int($affectedRows)) {
             return $affectedRows;
         }
     }
     if ($this->isNew() && !$this->isColumnModified(UserPeer::CREATED_AT)) {
         $this->setCreatedAt(time());
     }
     if ($this->isModified() && !$this->isColumnModified(UserPeer::UPDATED_AT)) {
         $this->setUpdatedAt(time());
     }
     if ($this->isDeleted()) {
         throw new PropelException("You cannot save an object that has been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $affectedRows = $this->doSave($con);
         $con->commit();
         foreach (sfMixer::getCallables('BaseUser:save:post') as $callable) {
             call_user_func($callable, $this, $con, $affectedRows);
         }
         UserPeer::addInstanceToPool($this);
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #7
0
ファイル: BaseShoutPeer.php プロジェクト: rayku/rayku
 /**
  * Selects a collection of Shout objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Shout objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ShoutPeer::addSelectColumns($c);
     $startcol2 = ShoutPeer::NUM_COLUMNS - ShoutPeer::NUM_LAZY_LOAD_COLUMNS;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     UserPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(ShoutPeer::POSTER_ID), array(UserPeer::ID), $join_behavior);
     $c->addJoin(array(ShoutPeer::RECIPIENT_ID), array(UserPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ShoutPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ShoutPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = ShoutPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ShoutPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = UserPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Shout) to the collection in $obj2 (User)
             $obj2->addShoutRelatedByPosterId($obj1);
         }
         // if joined row not null
         // Add objects for joined User rows
         $key3 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = UserPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = UserPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 UserPeer::addInstanceToPool($obj3, $key3);
             }
             // if obj3 loaded
             // Add the $obj1 (Shout) to the collection in $obj3 (User)
             $obj3->addShoutRelatedByRecipientId($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #8
0
 /**
  * Selects a collection of Link objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Link objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     LinkPeer::addSelectColumns($criteria);
     $startcol2 = LinkPeer::NUM_COLUMNS - LinkPeer::NUM_LAZY_LOAD_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(LinkPeer::USER_ID, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = LinkPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = LinkPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = LinkPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             LinkPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Link) to the collection in $obj2 (User)
             $obj2->addLink($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #9
0
 /**
  * Selects a collection of Subscription objects pre-filled with all related objects except Usergroup.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Subscription objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUsergroup(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     SubscriptionPeer::addSelectColumns($c);
     $startcol2 = SubscriptionPeer::NUM_COLUMNS - SubscriptionPeer::NUM_LAZY_LOAD_COLUMNS;
     ActivityPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (ActivityPeer::NUM_COLUMNS - ActivityPeer::NUM_LAZY_LOAD_COLUMNS);
     ZonePeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (ZonePeer::NUM_COLUMNS - ZonePeer::NUM_LAZY_LOAD_COLUMNS);
     CardPeer::addSelectColumns($c);
     $startcol5 = $startcol4 + (CardPeer::NUM_COLUMNS - CardPeer::NUM_LAZY_LOAD_COLUMNS);
     UserPeer::addSelectColumns($c);
     $startcol6 = $startcol5 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(SubscriptionPeer::ACTIVITY_ID), array(ActivityPeer::ID), $join_behavior);
     $c->addJoin(array(SubscriptionPeer::ZONE_ID), array(ZonePeer::ID), $join_behavior);
     $c->addJoin(array(SubscriptionPeer::CARD_ID), array(CardPeer::ID), $join_behavior);
     $c->addJoin(array(SubscriptionPeer::USER_ID), array(UserPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = SubscriptionPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = SubscriptionPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = SubscriptionPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             SubscriptionPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Activity rows
         $key2 = ActivityPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = ActivityPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = ActivityPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 ActivityPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Subscription) to the collection in $obj2 (Activity)
             $obj2->addSubscription($obj1);
         }
         // if joined row is not null
         // Add objects for joined Zone rows
         $key3 = ZonePeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = ZonePeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = ZonePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 ZonePeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Subscription) to the collection in $obj3 (Zone)
             $obj3->addSubscription($obj1);
         }
         // if joined row is not null
         // Add objects for joined Card rows
         $key4 = CardPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = CardPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $omClass = CardPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 CardPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (Subscription) to the collection in $obj4 (Card)
             $obj4->addSubscription($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key5 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol5);
         if ($key5 !== null) {
             $obj5 = UserPeer::getInstanceFromPool($key5);
             if (!$obj5) {
                 $omClass = UserPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj5 = new $cls();
                 $obj5->hydrate($row, $startcol5);
                 UserPeer::addInstanceToPool($obj5, $key5);
             }
             // if $obj5 already loaded
             // Add the $obj1 (Subscription) to the collection in $obj5 (User)
             $obj5->addSubscription($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #10
0
 /**
  * Persists this object to the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All modified related objects will also be persisted in the doSave()
  * method.  This method wraps all precipitate database operations in a
  * single transaction.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        doSave()
  */
 public function save(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("You cannot save an object that has been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     $isInsert = $this->isNew();
     try {
         $ret = $this->preSave($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseUser:save:pre') as $callable) {
             if (is_integer($affectedRows = call_user_func($callable, $this, $con))) {
                 $con->commit();
                 return $affectedRows;
             }
         }
         if ($isInsert) {
             $ret = $ret && $this->preInsert($con);
         } else {
             $ret = $ret && $this->preUpdate($con);
         }
         if ($ret) {
             $affectedRows = $this->doSave($con);
             if ($isInsert) {
                 $this->postInsert($con);
             } else {
                 $this->postUpdate($con);
             }
             $this->postSave($con);
             // symfony_behaviors behavior
             foreach (sfMixer::getCallables('BaseUser:save:post') as $callable) {
                 call_user_func($callable, $this, $con, $affectedRows);
             }
             UserPeer::addInstanceToPool($this);
         } else {
             $affectedRows = 0;
         }
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #11
0
 /**
  * Selects a collection of Session objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Session objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     SessionPeer::addSelectColumns($criteria);
     $startcol2 = SessionPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(SessionPeer::USER_ID, UserPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseSessionPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = SessionPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = SessionPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = SessionPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             SessionPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Session) to the collection in $obj2 (User)
             $obj2->addSession($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #12
0
 /**
  * Selects a collection of Task objects pre-filled with all related objects except Priority.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Task objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPriority(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     TaskPeer::addSelectColumns($criteria);
     $startcol2 = TaskPeer::NUM_COLUMNS - TaskPeer::NUM_LAZY_LOAD_COLUMNS;
     ProjectPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (ProjectPeer::NUM_COLUMNS - ProjectPeer::NUM_LAZY_LOAD_COLUMNS);
     StatusPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (StatusPeer::NUM_COLUMNS - StatusPeer::NUM_LAZY_LOAD_COLUMNS);
     UserPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(TaskPeer::PROJECT_ID, ProjectPeer::ID, $join_behavior);
     $criteria->addJoin(TaskPeer::STATUS_ID, StatusPeer::ID, $join_behavior);
     $criteria->addJoin(TaskPeer::LEAD_ID, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = TaskPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = TaskPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = TaskPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             TaskPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Project rows
         $key2 = ProjectPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = ProjectPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = ProjectPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 ProjectPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Task) to the collection in $obj2 (Project)
             $obj2->addTask($obj1);
         }
         // if joined row is not null
         // Add objects for joined Status rows
         $key3 = StatusPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = StatusPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = StatusPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 StatusPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Task) to the collection in $obj3 (Status)
             $obj3->addTask($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key4 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = UserPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = UserPeer::getOMClass(false);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 UserPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (Task) to the collection in $obj4 (User)
             $obj4->addTask($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #13
0
 /**
  * Selects a collection of LanguageObjectHistory objects pre-filled with all related objects except Language.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of LanguageObjectHistory objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptLanguage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(LanguageObjectHistoryPeer::DATABASE_NAME);
     }
     LanguageObjectHistoryPeer::addSelectColumns($criteria);
     $startcol2 = LanguageObjectHistoryPeer::NUM_HYDRATE_COLUMNS;
     ContentObjectPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + ContentObjectPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + UserPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + UserPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(LanguageObjectHistoryPeer::OBJECT_ID, ContentObjectPeer::ID, $join_behavior);
     $criteria->addJoin(LanguageObjectHistoryPeer::CREATED_BY, UserPeer::ID, $join_behavior);
     $criteria->addJoin(LanguageObjectHistoryPeer::UPDATED_BY, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = LanguageObjectHistoryPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = LanguageObjectHistoryPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = LanguageObjectHistoryPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             LanguageObjectHistoryPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined ContentObject rows
         $key2 = ContentObjectPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = ContentObjectPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = ContentObjectPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 ContentObjectPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (LanguageObjectHistory) to the collection in $obj2 (ContentObject)
             $obj2->addLanguageObjectHistory($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key3 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = UserPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = UserPeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 UserPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (LanguageObjectHistory) to the collection in $obj3 (User)
             $obj3->addLanguageObjectHistoryRelatedByCreatedBy($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key4 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = UserPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = UserPeer::getOMClass();
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 UserPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (LanguageObjectHistory) to the collection in $obj4 (User)
             $obj4->addLanguageObjectHistoryRelatedByUpdatedBy($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #14
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return    User A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `ID`, `EMAIL`, `PWD`, `ACTIVATE_TOKEN`, `RESET_PASSWORD_TOKEN`, `ROLE`, `DELETED`, `LANGUAGE`, `CREATED_AT`, `NAME`, `WEBSITE`, `SM_PROFILE` FROM `user` WHERE `ID` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new User();
         $obj->hydrate($row);
         UserPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #15
0
 /**
  * Selects a collection of GameMember objects pre-filled with all related objects except Game.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of GameMember objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptGame(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     GameMemberPeer::addSelectColumns($c);
     $startcol2 = GameMemberPeer::NUM_COLUMNS - GameMemberPeer::NUM_LAZY_LOAD_COLUMNS;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(GameMemberPeer::USER_ID), array(UserPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = GameMemberPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = GameMemberPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = GameMemberPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             GameMemberPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = UserPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (GameMember) to the collection in $obj2 (User)
             $obj2->addGameMember($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #16
0
ファイル: BaseUserPeer.php プロジェクト: rafd/SkuleCourses
 /**
  * Selects a collection of User objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of User objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseUserPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseUserPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserPeer::addSelectColumns($c);
     $startcol2 = UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS;
     EnumItemPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (EnumItemPeer::NUM_COLUMNS - EnumItemPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(UserPeer::TYPE_ID), array(EnumItemPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = UserPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = UserPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = UserPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             UserPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined EnumItem rows
         $key2 = EnumItemPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EnumItemPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = EnumItemPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EnumItemPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (User) to the collection in $obj2 (EnumItem)
             $obj2->addUser($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #17
0
ファイル: BaseUserQuery.php プロジェクト: dapepe/tymio
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 User A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `account_id`, `domain_id`, `deleted`, `name`, `firstname`, `lastname`, `phone`, `manager_of`, `is_admin`, `email`, `password_hash`, `number` FROM `user` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new User();
         $obj->hydrate($row);
         UserPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #18
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 User A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `email`, `pwd`, `activate_token`, `reset_password_token`, `role`, `deleted`, `language`, `created_at`, `name`, `website`, `sm_profile`, `oauth_signin` FROM `user` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new User();
         $obj->hydrate($row);
         UserPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #19
0
 /**
  * Selects a collection of Comment objects pre-filled with all related objects except Post.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of Comment objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPost(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     CommentPeer::addSelectColumns($criteria);
     $startcol2 = CommentPeer::NUM_COLUMNS - CommentPeer::NUM_LAZY_LOAD_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(CommentPeer::USER_ID, UserPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseCommentPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = CommentPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = CommentPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = CommentPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             CommentPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Comment) to the collection in $obj2 (User)
             $obj2->addComment($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #20
0
ファイル: BaseDocumentPeer.php プロジェクト: rapila/cms-base
 /**
  * Selects a collection of Document objects pre-filled with all related objects except DocumentData.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Document objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptDocumentData(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(DocumentPeer::DATABASE_NAME);
     }
     DocumentPeer::addSelectColumns($criteria);
     $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS;
     LanguagePeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + LanguagePeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + UserPeer::NUM_HYDRATE_COLUMNS;
     DocumentTypePeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + DocumentTypePeer::NUM_HYDRATE_COLUMNS;
     DocumentCategoryPeer::addSelectColumns($criteria);
     $startcol6 = $startcol5 + DocumentCategoryPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol7 = $startcol6 + UserPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol8 = $startcol7 + UserPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(DocumentPeer::LANGUAGE_ID, LanguagePeer::ID, $join_behavior);
     $criteria->addJoin(DocumentPeer::OWNER_ID, UserPeer::ID, $join_behavior);
     $criteria->addJoin(DocumentPeer::DOCUMENT_TYPE_ID, DocumentTypePeer::ID, $join_behavior);
     $criteria->addJoin(DocumentPeer::DOCUMENT_CATEGORY_ID, DocumentCategoryPeer::ID, $join_behavior);
     $criteria->addJoin(DocumentPeer::CREATED_BY, UserPeer::ID, $join_behavior);
     $criteria->addJoin(DocumentPeer::UPDATED_BY, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = DocumentPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             DocumentPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Language rows
         $key2 = LanguagePeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = LanguagePeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = LanguagePeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 LanguagePeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Document) to the collection in $obj2 (Language)
             $obj2->addDocument($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key3 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = UserPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = UserPeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 UserPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Document) to the collection in $obj3 (User)
             $obj3->addDocumentRelatedByOwnerId($obj1);
         }
         // if joined row is not null
         // Add objects for joined DocumentType rows
         $key4 = DocumentTypePeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = DocumentTypePeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = DocumentTypePeer::getOMClass();
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 DocumentTypePeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (Document) to the collection in $obj4 (DocumentType)
             $obj4->addDocument($obj1);
         }
         // if joined row is not null
         // Add objects for joined DocumentCategory rows
         $key5 = DocumentCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol5);
         if ($key5 !== null) {
             $obj5 = DocumentCategoryPeer::getInstanceFromPool($key5);
             if (!$obj5) {
                 $cls = DocumentCategoryPeer::getOMClass();
                 $obj5 = new $cls();
                 $obj5->hydrate($row, $startcol5);
                 DocumentCategoryPeer::addInstanceToPool($obj5, $key5);
             }
             // if $obj5 already loaded
             // Add the $obj1 (Document) to the collection in $obj5 (DocumentCategory)
             $obj5->addDocument($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key6 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol6);
         if ($key6 !== null) {
             $obj6 = UserPeer::getInstanceFromPool($key6);
             if (!$obj6) {
                 $cls = UserPeer::getOMClass();
                 $obj6 = new $cls();
                 $obj6->hydrate($row, $startcol6);
                 UserPeer::addInstanceToPool($obj6, $key6);
             }
             // if $obj6 already loaded
             // Add the $obj1 (Document) to the collection in $obj6 (User)
             $obj6->addDocumentRelatedByCreatedBy($obj1);
         }
         // if joined row is not null
         // Add objects for joined User rows
         $key7 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol7);
         if ($key7 !== null) {
             $obj7 = UserPeer::getInstanceFromPool($key7);
             if (!$obj7) {
                 $cls = UserPeer::getOMClass();
                 $obj7 = new $cls();
                 $obj7->hydrate($row, $startcol7);
                 UserPeer::addInstanceToPool($obj7, $key7);
             }
             // if $obj7 already loaded
             // Add the $obj1 (Document) to the collection in $obj7 (User)
             $obj7->addDocumentRelatedByUpdatedBy($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #21
0
ファイル: BaseJobPeer.php プロジェクト: Halfnhav4/datawrapper
 /**
  * Selects a collection of Job objects pre-filled with all related objects except Chart.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Job objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptChart(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(JobPeer::DATABASE_NAME);
     }
     JobPeer::addSelectColumns($criteria);
     $startcol2 = JobPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(JobPeer::USER_ID, UserPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = JobPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = JobPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = JobPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             JobPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Job) to the collection in $obj2 (User)
             $obj2->addJob($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #22
0
ファイル: BaseUserPeer.php プロジェクト: eddypre/Quirofano
 /**
  * Populates an object of the default type or an object that inherit from the default.
  *
  * @param      array $row PropelPDO resultset row.
  * @param      int $startcol The 0-based offset for reading from the resultset row.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  * @return array (User object, last column rank)
  */
 public static function populateObject($row, $startcol = 0)
 {
     $key = UserPeer::getPrimaryKeyHashFromRow($row, $startcol);
     if (null !== ($obj = UserPeer::getInstanceFromPool($key))) {
         // We no longer rehydrate the object, since this can cause data loss.
         // See http://www.propelorm.org/ticket/509
         // $obj->hydrate($row, $startcol, true); // rehydrate
         $col = $startcol + UserPeer::NUM_HYDRATE_COLUMNS;
     } else {
         $cls = UserPeer::OM_CLASS;
         $obj = new $cls();
         $col = $obj->hydrate($row, $startcol);
         UserPeer::addInstanceToPool($obj, $key);
     }
     return array($obj, $col);
 }
コード例 #23
0
ファイル: BaseUser.php プロジェクト: jldupont/jldupont.com
 /**
  * Persists this object to the database.
  * 
  * If the object is new, it inserts it; otherwise an update is performed.
  * All modified related objects will also be persisted in the doSave() 
  * method.  This method wraps all precipitate database operations in a 
  * single transaction.
  *
  * @param      PropelPDO $con	 
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        doSave()
  */
 public function save(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("You cannot save an object that has been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     try {
         $con->beginTransaction();
         $affectedRows = $this->doSave($con);
         $con->commit();
         UserPeer::addInstanceToPool($this);
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
コード例 #24
0
ファイル: BaseUserQuery.php プロジェクト: rapila/cms-base
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 User A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `username`, `password`, `digest_ha1`, `first_name`, `last_name`, `email`, `language_id`, `timezone`, `is_admin`, `is_backend_login_enabled`, `is_admin_login_enabled`, `is_inactive`, `password_recover_hint`, `backend_settings`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `users` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new User();
         $obj->hydrate($row);
         UserPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }