ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10215


Ignore:
Timestamp:
Jan 18, 2009, 10:55:35 PM (11 years ago)
Author:
icz
Message:

display is not right.

Location:
OpenPNE3/plugins/opAshiatoPlugin/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opAshiatoPlugin/trunk/config/schema.yml

    r9793 r10215  
    66    member_id_from: { type: integer, required: true, foreignTable: member, foreignReference: id, OnDelete: cascade }
    77    member_id_to: { type: integer, required: true, foreignTable: member, foreignReference: id, OnDelete: cascade }
     8    r_date: { type: DATE }
    89    updated_at: ~
    910
  • OpenPNE3/plugins/opAshiatoPlugin/trunk/lib/model/AshiatoPeer.php

    r10006 r10215  
    1414  {
    1515    $c = new Criteria();
     16    $c->clearSelectColumns()->addSelectColumn(AshiatoPeer::R_DATE);
    1617    $c->add(AshiatoPeer::MEMBER_ID_TO, $memberId);
    17    
     18    $c->addDescendingOrderByColumn(AshiatoPeer::R_DATE);
     19    $c->setDistinct();
     20    $c->setLimit($size);
     21    $stmt = self::doSelectStmt($c);
     22    while ($row = $stmt->fetch(PDO::FETCH_NUM))
     23    {
     24      $date[] = $row[0];
     25    }
     26
     27    $c2 = new Criteria();
     28    $c2->clearSelectColumns();
     29    $c2->add(AshiatoPeer::MEMBER_ID_TO, $memberId);
     30    $c2->add(AshiatoPeer::R_DATE,$date,Criteria::IN);
     31    $c2->addGroupByColumn(AshiatoPeer::MEMBER_ID_FROM);
     32    $c2->addGroupByColumn(AshiatoPeer::R_DATE);
     33    $c2->addDescendingOrderByColumn(AshiatoPeer::UPDATED_AT);
     34
    1835    $pager = new sfPropelPager('Ashiato', $size);
    1936    $pager->setPeerMethod('doSelectJoinMemberRelatedByMemberIdFrom');
    20     $pager->setCriteria($c);
     37    $pager->setCriteria($c2);
    2138   
    2239    $pager->setPage($page);
     
    2441
    2542    return $pager;
     43  }
     44
     45  public static function doSelectJoinMemberRelatedByMemberIdFrom(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
     46  {
     47
     48    foreach (sfMixer::getCallables('BaseAshiatoPeer:doSelectJoin:doSelectJoin') as $callable)
     49    {
     50      call_user_func($callable, 'BaseAshiatoPeer', $c, $con);
     51    }
     52
     53
     54    $c = clone $c;
     55
     56    if ($c->getDbName() == Propel::getDefaultDB()) {
     57      $c->setDbName(self::DATABASE_NAME);
     58    }
     59
     60    $c->addSelectColumn(AshiatoPeer::ID);
     61    $c->addSelectColumn(AshiatoPeer::MEMBER_ID_FROM);
     62    $c->addSelectColumn(AshiatoPeer::MEMBER_ID_TO);
     63    $c->addSelectColumn(AshiatoPeer::R_DATE);
     64    $c->addSelectColumn('MAX(' . AshiatoPeer::UPDATED_AT . ')');
     65    $startcol = (AshiatoPeer::NUM_COLUMNS - AshiatoPeer::NUM_LAZY_LOAD_COLUMNS);
     66    MemberPeer::addSelectColumns($c);
     67
     68    $c->addJoin(array(AshiatoPeer::MEMBER_ID_FROM,), array(MemberPeer::ID,), $join_behavior);
     69    $stmt = BasePeer::doSelect($c, $con);
     70    $results = array();
     71
     72    while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     73      $key1 = AshiatoPeer::getPrimaryKeyHashFromRow($row, 0);
     74      if (null !== ($obj1 = AshiatoPeer::getInstanceFromPool($key1))) {
     75                              } else {
     76
     77        $omClass = AshiatoPeer::getOMClass();
     78
     79        $cls = substr('.'.$omClass, strrpos('.'.$omClass, '.') + 1);
     80        $obj1 = new $cls();
     81        $obj1->hydrate($row);
     82        AshiatoPeer::addInstanceToPool($obj1, $key1);
     83      }
     84      $key2 = MemberPeer::getPrimaryKeyHashFromRow($row, $startcol);
     85      if ($key2 !== null) {
     86        $obj2 = MemberPeer::getInstanceFromPool($key2);
     87        if (!$obj2) {
     88
     89          $omClass = MemberPeer::getOMClass();
     90
     91          $cls = substr('.'.$omClass, strrpos('.'.$omClass, '.') + 1);
     92          $obj2 = new $cls();
     93          $obj2->hydrate($row, $startcol);
     94          MemberPeer::addInstanceToPool($obj2, $key2);
     95        }
     96                $obj2->addAshiatoRelatedByMemberIdFrom($obj1);
     97
     98      }
     99      $results[] = $obj1;
     100    }
     101    $stmt->closeCursor();
     102    return $results;
    26103  }
    27104
     
    40117    //$this->ashiatoConfigUpdate_span->getValue()
    41118    $c = new Criteria();
    42     $wait = date('Y-m-d H:i:s', strtotime('-' . sfConfig::get('update_span_minute')));
     119    $wait = date('Y-m-d H:i:s', strtotime('-' . sfConfig::get('app_update_span_minute') . 'minute'));
    43120    $c->add(AshiatoPeer::MEMBER_ID_FROM, $memberIdFrom);
    44121    $c->add(AshiatoPeer::MEMBER_ID_TO, $memberIdTo);
    45     $c->add(AshiatoPeer::UPDATED_AT, $wait, Criteria::LESS_THAN);
    46     if(self::doSelectOne($c)){
     122    $c->add(AshiatoPeer::UPDATED_AT, $wait, Criteria::GREATER_THAN);
     123    $stmt = self::doSelectStmt($c);
     124
     125    if(self::doCount($c)){
    47126      return false;
    48127    }
     
    51130    $ashiato->setMemberIdFrom($memberIdFrom);
    52131    $ashiato->setMemberIdTo($memberIdTo);
     132    $ashiato->setRDate(date());
    53133    $ashiato->save();
    54134    return $ashiato->getID();
Note: See TracChangeset for help on using the changeset viewer.