How to access Google Cloud datastore with php?

后端 未结 5 1502
旧巷少年郎
旧巷少年郎 2021-01-18 11:59

I am using Google app engine for my web app and I need to use a NoSQL database, so my best option is Google Cloud Datastore

Since I can\'t find a way to connect it w

5条回答
  •  一向
    一向 (楼主)
    2021-01-18 12:34

    Include google/cloud-datastore library via composer

    $ composer require google/cloud-datastore

    and you can use as Example below.

     'my_project'
    ]);
    
    // Create an entity
    $bob = $datastore->entity('Person');
    $bob['firstName'] = 'Bob';
    $bob['email'] = 'bob@example.com';
    $datastore->insert($bob);
    
    // Update the entity
    $bob['email'] = 'bobV2@example.com';
    $datastore->update($bob);
    
    // If you know the ID of the entity, you can look it up
    $key = $datastore->key('Person', '12345328897844');
    $entity = $datastore->lookup($key);
    

    More details: https://github.com/GoogleCloudPlatform/google-cloud-php#google-cloud-datastore-ga

提交回复
热议问题