Last active
December 29, 2015 15:19
-
-
Save birkir/7690109 to your computer and use it in GitHub Desktop.
Fix mysql Database driver for hhvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Database_MySQL_HHVM_Result { | |
protected $_ref; | |
public function current() | |
{ | |
if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row)) | |
return NULL; | |
// Increment internal row for optimization assuming rows are fetched in order | |
$this->_internal_row++; | |
// Get row as associated array | |
$row = mysql_fetch_assoc($this->_result); | |
if ($this->_as_object === TRUE OR is_string($this->_as_object)) | |
{ | |
if ( ! isset($this->_ref)) | |
{ | |
// Create reflection class of given class name or stdClass | |
$this->_ref = new ReflectionClass(is_string($this->_as_object) ? $this->_as_object : 'stdClass'); | |
} | |
// Get new instance whithout constructing it | |
$object = $this->_ref->newInstanceWithoutConstructor(); | |
foreach ($row as $column => $value) | |
{ | |
// Trigger the setter | |
$object->__set($column, $value); | |
} | |
// Construct the class with no parameter | |
$object->__construct(NULL); | |
return $object; | |
} | |
return $row; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment