diff --git a/doc/ChangeLog b/doc/ChangeLog index dfc9f3fce7..ef66516391 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -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 diff --git a/main/Base/Hstore.class.php b/main/Base/Hstore.class.php index 48bce8690d..baf43750c1 100644 --- a/main/Base/Hstore.class.php +++ b/main/Base/Hstore.class.php @@ -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; diff --git a/test/main/HstoreTest.class.php b/test/main/HstoreTest.class.php new file mode 100644 index 0000000000..8938d868a4 --- /dev/null +++ b/test/main/HstoreTest.class.php @@ -0,0 +1,26 @@ + 'qqer', + 'f' => 'qs34$9&)_@+#qer', + ); + + $test = Hstore::make($array); + $test2= Hstore::create($test->toString()); + + $this->assertEquals($test->toString(), $test2->toString()); + } + }