Example #1
0
 /**
  * 結果セットを連想配列に変換する
  *
  * @param P2KeyValueStore_Codec_Interface $codec
  * @return array
  */
 public function toArray(P2KeyValueStore_Codec_Interface $codec = null)
 {
     if ($codc === null) {
         $key = $this->arkey;
         $value = $this->value;
     } else {
         $key = $codec->decodeKey($this->arkey);
         $value = $codec->decodeValue($this->value);
     }
     return array('id' => (int) $this->id, 'key' => $key, 'value' => $value, 'mtime' => (int) $this->mtime, 'order' => (int) $this->sort_order);
 }
Example #2
0
 /**
  * キーに対応するレコードを削除する
  *
  * @param string $key
  * @return bool
  */
 public function delete($key)
 {
     $stmt = $this->_prepare(self::Q_DELETE);
     $stmt->bindValue(':key', $this->_codec->encodeKey($key));
     if ($stmt->execute()) {
         return $stmt->rowCount() == 1;
     } else {
         return false;
     }
 }