Skip to content

Commit 3d22725

Browse files
authored
Updates cloudsql example to align better with docs (GoogleCloudPlatform#661)
1 parent e97b51c commit 3d22725

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

appengine/php72/cloudsql/app-postgres.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# This app.yaml is for deploying to instances of Cloud SQL running PostgreSQL.
22
# See the default app.yaml for running Cloud SQL with MySQL.
33

4+
# [START gae_cloudsql_postgres_env]
45
runtime: php72
56

6-
# Defaults to "serve index.php" and "serve public/index.php". Can be used to
7-
# serve a custom PHP front controller (e.g. "serve backend/index.php") or to
8-
# run a long-running PHP script as a worker process (e.g. "php worker.php").
9-
#
10-
# entrypoint: serve index.php
11-
12-
# [START gae_cloudsql_postgres_env]
137
env_variables:
148
# Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
159
# values obtained when configuring your Cloud SQL instance.

appengine/php72/cloudsql/app.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# This app.yaml is for deploying to instances of Cloud SQL running MySQL.
22
# See app-postgres.yaml for running Cloud SQL with PostgreSQL.
33

4+
# [START gae_cloudsql_mysql_env]
45
runtime: php72
56

6-
# Defaults to "serve index.php" and "serve public/index.php". Can be used to
7-
# serve a custom PHP front controller (e.g. "serve backend/index.php") or to
8-
# run a long-running PHP script as a worker process (e.g. "php worker.php").
9-
#
10-
# entrypoint: serve index.php
11-
12-
# [START gae_cloudsql_mysql_env]
137
env_variables:
148
# Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
159
# values obtained when configuring your Cloud SQL instance.

appengine/php72/cloudsql/index.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
# [START gae_cloudsql_example]
2828
// Create the PDO object to talk to CloudSQL. Use the following variables:
2929
//
30-
// $dsn = "mysql:dbname=DATABASE;unix_socket=/cloudsql/CONNECTION_NAME";
31-
// $user = 'YOUR_CLOUDSQL_USER';
32-
// $password = 'YOUR_CLOUDSQL_PASSWORD';
30+
// $dsn = "mysql:dbname=DATABASE;unix_socket=/cloudsql/CONNECTION_NAME";
31+
// $user = 'YOUR_CLOUDSQL_USER';
32+
// $password = 'YOUR_CLOUDSQL_PASSWORD';
3333
//
3434
// If the unix socket is unavailable, try to connect using TCP. This will work
3535
// if you're running a local MySQL server or using the Cloud SQL proxy, for example:
@@ -38,7 +38,9 @@
3838
//
3939
// This will mean your DSN for connecting locally to Cloud SQL would look like this:
4040
//
41-
// $dsn = "mysql:dbname=DATABASE;host=127.0.0.1";
41+
// $dsn = "mysql:dbname=DATABASE;host=127.0.0.1";
42+
//
43+
// For PostgreSQL examples see `app-postgres.yaml`
4244
//
4345
$db = new PDO($dsn, $user, $password);
4446

@@ -59,6 +61,10 @@
5961
// Query existing guestbook entries.
6062
$results = $db->query('SELECT * from entries');
6163

64+
// Now you can use the PDOStatement object to print or iterate over the results:
65+
//
66+
// var_dump($results->fetchAll(PDO::FETCH_ASSOC));
67+
//
6268
# [END gae_cloudsql_example]
6369
?>
6470

0 commit comments

Comments
 (0)