Skip to content

Conversation

@marcelojeff
Copy link

When i was trying to get the current Row from a ResultSet ($query->getResultSet()->current();) that can be empty, i'd got the follow error:

Notice: Undefined offset: 0 in vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Query/ResultSet.php on line 54

So, i'm suggesting to verify the offset existence, then return null if it not exists.

Thanks in advance, and sorry for my english!

@jadell
Copy link
Owner

jadell commented Nov 15, 2013

Use count($resultSet) to determine if the result set is empty or not.

The ResultSet and Row classes are meant to act like PHP arrays as much as possible. The warning you are seeing is the same one you would get if trying to access an array key that didn't exist. I don't think it is a good idea to hide those semantics. You shouldn't be calling current on the ResultSet; that is merely an implementation method for the Iterator interface.

@jadell
Copy link
Owner

jadell commented Nov 17, 2013

If you think null is the proper response to asking for a non-existent row, that is fine (that does mirror the array semantics), but a notice should still be throw using trigger_error. Also, please write a test for the behavior. The Query\Row class should also follow the same behavior.

@marcelojeff
Copy link
Author

Nice! I'll work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants