示例#1
0
 public static function getUserBikesWithAll()
 {
     $bikeArray = UserBikesPeer::getUserBikes();
     $shelfItem = new UserBikes();
     $shelfItem->setBikeMake("(All Bikes)");
     array_push($bikeArray, $shelfItem);
     return $bikeArray;
 }
示例#2
0
 public function executeDelete()
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->bikeid = $this->getRequestParameter('bikeid');
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         //delete user_stat and equipment
         $c = new Criteria();
         $c->add(UserStatsPeer::USER_ID, $userId);
         $c->add(UserStatsPeer::BIKE_ID, $this->bikeid);
         $s = UserStatsPeer::doSelectJoinAll($c);
         foreach ($s as $stat) {
             foreach ($stat->getUserStatEquips() as $equip) {
                 $equip->delete();
             }
             $stat->delete();
         }
         //move equipment to shelf
         $c = new Criteria();
         $c->add(UserEquipementPeer::USER_ID, $userId);
         $c->add(UserEquipementPeer::BIKE_ID, $this->bikeid);
         $equip = UserEquipementPeer::doSelect($c);
         foreach ($equip as $e) {
             $e->setBikeId(null);
             $e->save();
         }
         //now delete bike
         $user_bikes = UserBikesPeer::retrieveByPk($this->bikeid);
         $user_bikes->delete();
         return $this->redirect('userbike/index');
     }
 }
示例#3
0
                </td>
                <td>
                    <div class="form-row">
                        <label for="title">From Date:</label>
                        <?php 
echo input_date_tag('from_date', 'now', 'rich=true');
?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-row">
                        <label for="title">Bike:</label>
                        <?php 
echo select_tag('user_bike_id', objects_for_select(UserBikesPeer::getUserBikesWithAll(), 'getUserBikeId', 'getBikeMake', $bike), array('style' => 'width:150px'));
?>
                    </div>
                </td>
                <td>
                    <div class="form-row">
                        <label for="title">To Date:</label>
                        <?php 
echo input_date_tag('to_date', 'now', 'rich=true');
?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-row">
示例#4
0
 /**
  * Returns the number of related UserBikes objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related UserBikes objects.
  * @throws     PropelException
  */
 public function countUserBikess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UsersPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collUserBikess === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(UserBikesPeer::USER_ID, $this->user_id);
             $count = UserBikesPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(UserBikesPeer::USER_ID, $this->user_id);
             if (!isset($this->lastUserBikesCriteria) || !$this->lastUserBikesCriteria->equals($criteria)) {
                 $count = UserBikesPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collUserBikess);
             }
         } else {
             $count = count($this->collUserBikess);
         }
     }
     $this->lastUserBikesCriteria = $criteria;
     return $count;
 }
示例#5
0
 /**
  * Get the associated UserBikes object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     UserBikes The associated UserBikes object.
  * @throws     PropelException
  */
 public function getUserBikes(PropelPDO $con = null)
 {
     if ($this->aUserBikes === null && $this->bike_id !== null) {
         $c = new Criteria(UserBikesPeer::DATABASE_NAME);
         $c->add(UserBikesPeer::USER_BIKE_ID, $this->bike_id);
         $this->aUserBikes = UserBikesPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aUserBikes->addUserEquipements($this);
         		 */
     }
     return $this->aUserBikes;
 }
示例#6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(UserBikesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(UserBikesPeer::DATABASE_NAME);
         $criteria->add(UserBikesPeer::USER_BIKE_ID, $pks, Criteria::IN);
         $objs = UserBikesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
示例#7
0
 /**
  * Selects a collection of UserStats objects pre-filled with all related objects except UserRides.
  *
  * @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 UserStats objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUserRides(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseUserStatsPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BaseUserStatsPeer', $c, $con);
     }
     $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);
     }
     UserStatsPeer::addSelectColumns($c);
     $startcol2 = UserStatsPeer::NUM_COLUMNS - UserStatsPeer::NUM_LAZY_LOAD_COLUMNS;
     UserBikesPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (UserBikesPeer::NUM_COLUMNS - UserBikesPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(UserStatsPeer::BIKE_ID), array(UserBikesPeer::USER_BIKE_ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = UserStatsPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = UserStatsPeer::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 = UserStatsPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             UserStatsPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined UserBikes rows
         $key2 = UserBikesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserBikesPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = UserBikesPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserBikesPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (UserStats) to the collection in $obj2 (UserBikes)
             $obj2->addUserStats($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
示例#8
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = UserBikesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setUserId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserBikeId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setBikeYear($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setBikeMake($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setBikeModel($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setEquipFunction($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setDescription($arr[$keys[6]]);
     }
 }
示例#9
0
?>

    </div>

    <div class="form-row">
        <label for="desc">Model:</label>
        <?php 
echo input_tag('model', $model);
?>

    </div>

    <div class="form-row">
     <label for="assoc">Equipment Association:</label>
        <?php 
echo select_tag('assocId', objects_for_select(UserBikesPeer::getUserBikesWithShelf(), 'getUserBikeId', 'getBikeMake', $bike), array('style' => 'width:150px'));
?>
    </div>

    <div class="form-row">
     <label for="type">Equipment Type:</label>
        <?php 
echo select_tag('equip_id', objects_for_select(BaseEquipFunctionPeer::doSelect(new Criteria()), 'getFunctionId', 'getFunctionName', $type), array('style' => 'width:150px'));
?>
    </div>

    <div class="form-row">
        <label for="cost">Purchase Cost:</label>
        <?php 
echo input_tag('cost', $cost);
?>