/** * Writes data to storage. * * Warning: this function is not working transactionally. * In case of an error, you may end up with old data deleted and * new data never added! * * @param string $key * @param mixed $data * * @returns void */ public function write($key, $data) { Preconditions::checkIsString($key); $this->remove($key); if (!$this->insertStatement) { $this->insertStatement = $this->prepareInsert(); } $statement = $this->insertStatement; $statement->bindValue('key', $key); $statement->bindValue('data', Serializer::serialize($data)); if (!$statement->execute()) { throw new sfStorageException("Problem removing key '{$key}'"); } }
private function serializeDeserialize($value) { return Serializer::deserialize(Serializer::serialize($value)); }