Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2012-06-04 Evgeny M. Stepanov

* main/Base/Hstore.class.php: fix

2012-05-31 Alexey S. Denisov

* main/DAOs/StorableDAO.class.php: fix merge object with self
Expand Down
12 changes: 6 additions & 6 deletions main/Base/Hstore.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,24 @@ public function toValue($raw)
return $this;

$return = null;
eval("\$return = array({$raw});");
eval('$return = array('.$raw.');');
$this->properties = $return;

return $this;
}

public function toString()
{
if (empty($this->properties))
return null;

$string = '';

foreach ($this->properties as $k => $v) {
if ($v !== null)
$string .= "\"{$this->quoteValue($k)}\"=>\"{$this->quoteValue($v)}\",";
$string .= "'".$this->quoteValue($k)."'=>'".$this->quoteValue($v)."',";
else
$string .= "\"{$this->quoteValue($k)}\"=>NULL,";
$string .= "'{$this->quoteValue($k)}'=>NULL,";
}

return $string;
Expand Down
26 changes: 26 additions & 0 deletions test/main/HstoreTest.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/***************************************************************************
* Copyright (C) by Evgeny M. Stepanov *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/

final class HstoreTest extends TestCase
{
public function testRun()
{
$array = array(
'1' => 'qqer',
'f' => 'qs34$9&)_@+#qer',
);

$test = Hstore::make($array);
$test2= Hstore::create($test->toString());

$this->assertEquals($test->toString(), $test2->toString());
}
}