Skip to content

Commit

Permalink
Fix legacy examples. Resolves #78.
Browse files Browse the repository at this point in the history
  • Loading branch information
twalder-docnet committed Dec 22, 2015
1 parent 4a44eeb commit 5edf1d5
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/ancestor_key_lookups.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$obj_person_schema = (new GDS\Schema('Person'))->addString('name')->addString('description');

$obj_store = new GDS\Store($obj_gateway, $obj_person_schema);
$obj_store = new GDS\Store($obj_person_schema, $obj_gateway);

// Load the parent (run 'ancestor_keys.php' if needed to create it)
$obj_stored_parent = $obj_store->fetchOne("SELECT * FROM Person WHERE __key__ = KEY(Person, 'parent@example.com')");
Expand Down
2 changes: 1 addition & 1 deletion examples/ancestor_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$obj_person_schema = (new GDS\Schema('Person'))->addString('name')->addString('description');

$obj_store = new GDS\Store($obj_gateway, $obj_person_schema);
$obj_store = new GDS\Store($obj_person_schema, $obj_gateway);

// Create the parent
$obj_john = new \GDS\Entity();
Expand Down
2 changes: 1 addition & 1 deletion examples/ancestor_keys_auto_insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$obj_person_schema = (new GDS\Schema('Person'))->addString('name')->addString('description');

$obj_store = new GDS\Store($obj_gateway, $obj_person_schema);
$obj_store = new GDS\Store($obj_person_schema, $obj_gateway);

// Create the parent
$obj_john = $obj_store->createEntity();
Expand Down
2 changes: 1 addition & 1 deletion examples/auto_insert_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
require_once('boilerplate.php');

$obj_store = new GDS\Store($obj_gateway, 'Temperatures');
$obj_store = new GDS\Store('Temperatures', $obj_gateway);

// Delete ALL
// $obj_store->delete($obj_store->fetchAll());
Expand Down
13 changes: 13 additions & 0 deletions examples/boilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@

require_once('Book.php');

// ============================================================================
// ============================================================================
// IMPORTANT - examples using this file operate on the remote Google API client
// ============================================================================
// ============================================================================

// We'll need a Google_Client, use our convenience method
$obj_client = GDS\Gateway\GoogleAPIClient::createGoogleClient(GDS_APP_NAME, GDS_SERVICE_ACCOUNT_NAME, GDS_KEY_FILE_PATH);

// Gateway requires a Google_Client and Dataset ID
$obj_gateway = new GDS\Gateway\GoogleAPIClient($obj_client, GDS_DATASET_ID);

// Alternative native gateway, auto-detect dataset. Should work in dev or live AppEngine
// But not in scripts.
$obj_gateway = new GDS\Gateway\ProtoBuf();

// ============================================================================
// ============================================================================

// Define our Model Schema
$obj_book_schema = (new GDS\Schema('Book'))
->addString('title')
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime_binding.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
->addDatetime('due', TRUE);

// Store requires a Gateway and Schema
$obj_task_store = new GDS\Store($obj_gateway, $obj_task_schema);
$obj_task_store = new GDS\Store($obj_task_schema, $obj_gateway);

// Insert some data, with datetime binding
$obj_task_1 = $obj_task_store->createEntity([
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
require_once('boilerplate.php');

$obj_store = new GDS\Store($obj_gateway, 'Friend');
$obj_store = new GDS\Store('Friend', $obj_gateway);

// So now create a simple Model object
$obj_charlie = new GDS\Entity();
Expand Down
2 changes: 1 addition & 1 deletion examples/fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
describeResult($obj_book);
}

$obj_store = new GDS\Store($obj_gateway, 'Contact');
$obj_store = new GDS\Store('Contact', $obj_gateway);
$arr_contacts = $obj_store->fetchByNames(['tom@docnet.nu', 'beermonster@gmail.com']);
foreach($arr_contacts as $obj_contact) {
echo " Found: {$obj_contact->first_name}, {$obj_contact->last_name}", PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion examples/list_create.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
->addStringList('tags', TRUE);

// Configure the Store
$obj_store = new GDS\Store($obj_gateway, $obj_contact_schema);
$obj_store = new GDS\Store($obj_contact_schema, $obj_gateway);

// Create 1
$obj_contact1 = $obj_store->createEntity([
Expand Down
2 changes: 1 addition & 1 deletion examples/list_fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
->addStringList('tags', TRUE);

// Configure the Store
$obj_store = new GDS\Store($obj_gateway, $obj_contact_schema);
$obj_store = new GDS\Store($obj_contact_schema, $obj_gateway);

// A couple of tests
show($obj_store->fetchAll("SELECT * FROM Contact_v1 WHERE tags = 'newsletter' AND tags = 'customer'"));
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$obj_gateway = new GDS\Gateway\GoogleAPIClient($obj_client, GDS_DATASET_ID);

// Store requires a Gateway and Kind
$obj_book_store = new GDS\Store($obj_gateway, 'Book');
$obj_book_store = new GDS\Store('Book', $obj_gateway);

// Fetch a record
$obj_book = $obj_book_store->fetchOne();
Expand Down

0 comments on commit 5edf1d5

Please sign in to comment.