Пример #1
0
 /**
  * データベースモデルを初期化する。
  * 初期の値を配列で渡すことで、その値でモデルを構築する。
  */
 public function __construct($accessTable, $values = array())
 {
     parent::__construct($accessTable->getColumns(), $values);
     $this->distinct = false;
     $this->access = $accessTable;
     $this->primary_keys = $this->access->getPrimaryKeys();
     $this->values_org = array();
     $this->values = array();
     $this->ignoreOperator = false;
     foreach ($this->access->getColumns() as $column) {
         $this->columns[] = $column;
         $this->values_org[$column] = "";
         $this->values[$column] = "";
     }
     $this->setValues($values);
     $this->setGroupBy();
     $this->limit();
 }
Пример #2
0
 /**
  * キャッシュを利用するためのメソッド
  */
 protected static function cacheData($key, $value = null)
 {
     if (!self::$cached || self::$cachedTime != Vizualizer::now()->date("YmdHis")) {
         // キャッシュデータが無いか、キャッシュ時間が更新されている場合は初期化
         self::$cachedTime = Vizualizer::now()->date("YmdHis");
         self::$cached = array();
     }
     if ($value !== null) {
         // 値が設定されている場合にはキーに対応する値に設定
         self::$cached[$key] = $value;
     }
     // キャッシュが存在する場合には値を返し、存在しない場合にはnullを返す。
     if (array_key_exists($key, self::$cached)) {
         return self::$cached[$key];
     }
     return null;
 }