0

I've used mongodb in the past and I want to use similar schema. I've tried to create it using PHP driver but it doesn't work as I expected. So my guesses were either rethinkdb does not support it or php driver is not capable to do this.

r\table('User')->insert([
        'username' => 'Something',
        'skills' => [
            'php' => 10,
            'html' => 15 
        ]
        ])->run($conn)

result in RethinkDB administrator js client:

{
    "username":  "Something" ,
    "id":  "899a2693-dd94-4670-a496-05626a88d190" ,
    "skills": { }
}

What do you suggest and how should I do this?

ewooycom
  • 2,651
  • 5
  • 30
  • 52
  • The quoted array is missing a ' after Something - it should be 'Something', not 'Something, – ckm Dec 31 '13 at 00:05

1 Answers1

3

It seems to work with PHP 5.4.13, RethinkDB 1.5.1 and the lastest version of php-rql.

r\table('User')->insert([
        'username' => 'Something',
        'skills' => [
            'php' => 10,
            'html' => 15 
        ]
])->run($conn);

It gives the following results:

$result = r\db("test")->table("user")->run($conn);
print_r($result->toNative());


Array
(
    [0] => Array
        (
            [username] => Something
            [skills] => Array
                (
                    [php] => 10
                    [html] => 15
                )

            [id] => 2c66490f-72da-49ad-9692-a85366ce94ab
        )

)

And in the Data Explorer:

[

    {
        "username": "Something" ,
        "skills": {
            "php": 10 ,
            "html": 15
        } ,
        "id": "2c66490f-72da-49ad-9692-a85366ce94ab"
    }

]
Etienne Laurin
  • 6,731
  • 2
  • 27
  • 31
  • I had update later in the code and haven't noticed. Thanks, your answer made me recheck everything. – ewooycom May 19 '13 at 08:56