Skip to content

Commit aad33d6

Browse files
angelafunkbshaffer
authored andcommitted
appengine php72 cloudsql region tags (GoogleCloudPlatform#625)
1 parent 3786e20 commit aad33d6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

appengine/php72/cloudsql/index.php

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

18-
# [START gae_cloudsql_connect]
18+
# [START gae_cloudsql_example]
1919
// Connect to CloudSQL from App Engine.
2020
$dsn = getenv('CLOUDSQL_DSN');
2121
$user = getenv('CLOUDSQL_USER');
2222
$password = getenv('CLOUDSQL_PASSWORD');
2323
if (!isset($dsn, $user) || false === $password) {
2424
throw new Exception('Set CLOUDSQL_DSN, CLOUDSQL_USER, and CLOUDSQL_PASSWORD environment variables');
2525
}
26-
# [END gae_cloudsql_connect]
2726

28-
# [START gae_cloudsql_create_tables]
2927
// Create the PDO object to talk to CloudSQL
3028
$db = new PDO($dsn, $user, $password);
3129

@@ -34,13 +32,11 @@
3432
. 'guestName VARCHAR(255), '
3533
. 'content VARCHAR(255))');
3634
$result = $stmt->execute();
37-
# [END gae_cloudsql_create_tables]
3835

3936
if (false === $result) {
4037
exit("Error: " . $stmt->errorInfo()[2]);
4138
}
4239

43-
# [START gae_cloudsql_insert]
4440
// Insert a new row into the guestbook on POST
4541
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
4642
$stmt = $db->prepare('INSERT INTO entries (guestName, content) VALUES (:name, :content)');
@@ -52,15 +48,12 @@
5248
print("Error: " . $stmt->errorInfo()[2]);
5349
}
5450
}
55-
# [END gae_cloudsql_insert]
5651

57-
# [START gae_cloudsql_query]
5852
// Show existing guestbook entries.
5953
$results = $db->query('SELECT * from entries');
60-
# [END gae_cloudsql_query]
6154

6255
?>
63-
# [START gae_cloudsql_results] ?>
56+
?>
6457
6558
6659
if ($results->rowCount() > 0): ?>
@@ -78,4 +71,4 @@
7871
7972
8073
81-
# [END gae_cloudsql_results] ?>
74+
# [END gae_cloudsql_example]?>

0 commit comments

Comments
 (0)