gventuri / simple-json-db

A simple json db class written in php
10 stars 5 forks source link

Multidimensional ARRAY. #1

Open MaruanBO opened 2 years ago

MaruanBO commented 2 years ago

Im trying to make the original code with the next json (37K)

https://raw.githubusercontent.com/MaruanBO/es/main/ES.json

 ```

$file = DIR . '/postal_code/ES.json';

    $json = file_get_contents($file);
    $data = [];

    foreach(json_decode($json, true) as $key) {
        $data[] = $key["fields"]["postal_code"];
    }

    $query = [
        $data => 18230
    ];

    $jsonDB= new JsonToDb($file);
    dump($jsonDB->getList($data, ["on" => "postal_code", "order" => "ASC"]));
    die();


returns : Warning: Illegal offset type
gventuri commented 2 years ago

Hi @MaruanBO, thank you so much for contacting me. At the moment, queries with multidimensional arrays are not supported, but sounds like a very interesting feature, and something that I'd love to add to the library.

It should be pretty straightforward to implement, I will work on it in the next few days!