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

Changeset 10085


Ignore:
Timestamp:
Jan 11, 2009, 3:37:38 PM (11 years ago)
Author:
ogawa
Message:

reduced SQL queries by fetching SnsConfig? and NaviI18N once

Location:
OpenPNE3/trunk/lib/model
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/model/NaviPeer.php

    r10003 r10085  
    2323    $c->add(self::TYPE, $type);
    2424    $c->addAscendingOrderByColumn(self::SORT_ORDER);
    25     return self::doSelect($c);
     25
     26    return self::doSelectWithI18n($c);
    2627  }
    2728
  • OpenPNE3/trunk/lib/model/SnsConfigPeer.php

    r10003 r10085  
    1818class SnsConfigPeer extends BaseSnsConfigPeer
    1919{
     20  protected static $configs;
     21
    2022  public static function retrieveByName($name)
    2123  {
    22     $c = new Criteria();
    23     $c->add(self::NAME, $name);
     24    $configs = self::getConfigs();
    2425
    25     $result = self::doSelectOne($c);
    26     return $result;
     26    return (isset($configs[$name])) ? $configs[$name] : null;
    2727  }
    2828
    2929  public static function get($name, $default = null)
    3030  {
    31     $config = self::retrieveByName($name);
    32     return ($config) ? $config->getValue() : $default;
     31    return (!is_null($config = self::retrieveByName($name))) ? $configs->getValue() : $default;
    3332  }
    3433
     
    4443    return $config->save();
    4544  }
     45
     46  protected static function getConfigs()
     47  {
     48    if (is_null(self::$configs))
     49    {
     50      self::$configs = array();
     51      foreach (self::doSelect(new Criteria()) as $config)
     52      {
     53        self::$configs[$config->getName()] = $config;
     54      }
     55    }
     56
     57    return self::$configs;
     58  }
    4659}
Note: See TracChangeset for help on using the changeset viewer.