Skip to content

Commit

Permalink
dirty fix: array_combine() expects parameter 1 to be array, string given
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandinsh committed Oct 15, 2019
1 parent 5612f8a commit 17a5192
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Redis/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function commit()
public function query($command)
{
$response = $this->redisCommand('GRAPH.QUERY', $this->name, $command);
return new Graph\Query\Result($response);
$responser = new Graph\Query\Result($response);
return $responser;

}

public function explain($query)
Expand Down
17 changes: 12 additions & 5 deletions src/Redis/Graph/Query/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,29 @@ public function prettyPrint()

private function parseResult($response)
{

if (!isset($response[0]) || !is_array($response[0])) {
return;
}
$this->keys = array_shift($response[0]);
foreach ($response[0] as $val) {
$this->values[] = array_combine($this->keys, $val);

$this->keys = array_shift($response);

if(isset($response[0])){
foreach ($response[0] as $val) {
$this->values[] = array_combine($this->keys, $val);
}
}

}

private function parseStats($response)
{
if (!isset($response[1]) || !is_array($response[1])) {

if (!isset($response[0]) || !is_array($response[0])) {
return;
}

foreach ($response[1] as $line) {
foreach ($response[0] as $line) {
if (preg_match('/^Labels added:(.*)$/', $line, $matches)) {
$this->stats['labels_added'] = (int)(trim($matches[1]));
} elseif (preg_match('/^Nodes created:(.*)$/', $line, $matches)) {
Expand Down

0 comments on commit 17a5192

Please sign in to comment.