JsonDB.class.php icon indicating copy to clipboard operation
JsonDB.class.php copied to clipboard

class returns table as an array but fails to save one

Open codeofsumit opened this issue 10 years ago • 2 comments

I'm a PHP beginner and this is something I really don't understand.

JSON

[]

PHP

$items = new JsonTable("../itemDB.json");

$currentItems = $items -> selectAll();

$items -> updateAll($currentItems);

$result = $items -> selectAll();

echo $result

Do that 5 times and you get

[[[[[]]]]]

why? What do I have to do with the array from selectAll() so it can get saved again without the weird nesting?

If I understand this correctly, selectAll gets the complete table while updateAll updates the contents of the table. What are my options here?

codeofsumit avatar Jan 07 '15 11:01 codeofsumit

Check this https://github.com/efesaid/JsonDB.class.php/commit/380551ff78a8ea04a84b821401f5ef85d70eae47 pull request, it will fix your problem.

edit : commit updated.

saitima avatar Jan 07 '15 11:01 saitima

@efesaid solved it, thanks!

codeofsumit avatar Jan 08 '15 14:01 codeofsumit