Skip to content

Commit dad1d2d

Browse files
Restore createTables.php and accomodate comments on pull request.
Add tests.
1 parent 37ad159 commit dad1d2d

File tree

8 files changed

+1276
-498
lines changed

8 files changed

+1276
-498
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
/**
3+
* Copyright 2015 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
// Install composer dependencies with "composer install"
19+
// @see http://getcomposer.org for more information.
20+
require __DIR__ . '/vendor/autoload.php';
21+
22+
$app = require __DIR__ . '/app.php';
23+
24+
/** @var PDO $db */
25+
$db = $app['database'];
26+
27+
# [START create_tables]
28+
// create the tables
29+
$stmt = $db->prepare('CREATE TABLE entries (
30+
entryID INT NOT NULL AUTO_INCREMENT,
31+
guestName VARCHAR(255),
32+
content VARCHAR(255),
33+
PRIMARY KEY(entryID)
34+
)');
35+
36+
$result = $stmt->execute();
37+
# [END create_tables]
38+
39+
if (false === $result) {
40+
printf("Error: %s\n", $stmt->errorInfo()[2]);
41+
} else {
42+
printf('Tables created');
43+
}

appengine/standard/users/app.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
# [START get_current_user]
19-
use google\appengine\api\users\User;
18+
# [START import]
2019
use google\appengine\api\users\UserService;
20+
# [END import]
2121
use Silex\Application;
2222

2323
// create the Silex application
2424
$app = new Application();
2525

2626
$app->get('/', function () use ($app) {
27+
# [START get_current_user]
2728
$user = UserService::getCurrentUser();
2829

2930
if (isset($user)) {
@@ -34,7 +35,7 @@
3435
return sprintf('Sign in or register',
3536
UserService::createLoginUrl('/'));
3637
}
38+
# [END get_current_user]
3739
});
38-
# [END get_current_user]
3940

4041
return $app;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"require": {
3-
"silex/silex": "^1.3",
4-
"php-http/guzzle6-adapter": "^1.0",
5-
"google/apiclient": "^1.1"
3+
"silex/silex": "^1.3"
64
},
75
"require-dev": {
6+
"phpunit/phpunit": "~4",
7+
"guzzlehttp/guzzle": "~6.0",
88
"symfony/browser-kit": "^3.0"
99
}
1010
}

0 commit comments

Comments
 (0)