File tree Expand file tree Collapse file tree 3 files changed +12
-18
lines changed Expand file tree Collapse file tree 3 files changed +12
-18
lines changed Original file line number Diff line number Diff line change 1
1
# This app.yaml is for deploying to instances of Cloud SQL running PostgreSQL.
2
2
# See the default app.yaml for running Cloud SQL with MySQL.
3
3
4
+ # [START gae_cloudsql_postgres_env]
4
5
runtime : php72
5
6
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]
13
7
env_variables :
14
8
# Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
15
9
# values obtained when configuring your Cloud SQL instance.
Original file line number Diff line number Diff line change 1
1
# This app.yaml is for deploying to instances of Cloud SQL running MySQL.
2
2
# See app-postgres.yaml for running Cloud SQL with PostgreSQL.
3
3
4
+ # [START gae_cloudsql_mysql_env]
4
5
runtime : php72
5
6
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]
13
7
env_variables :
14
8
# Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
15
9
# values obtained when configuring your Cloud SQL instance.
Original file line number Diff line number Diff line change 27
27
# [START gae_cloudsql_example]
28
28
// Create the PDO object to talk to CloudSQL. Use the following variables:
29
29
//
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';
33
33
//
34
34
// If the unix socket is unavailable, try to connect using TCP. This will work
35
35
// if you're running a local MySQL server or using the Cloud SQL proxy, for example:
38
38
//
39
39
// This will mean your DSN for connecting locally to Cloud SQL would look like this:
40
40
//
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`
42
44
//
43
45
$ db = new PDO ($ dsn , $ user , $ password );
44
46
59
61
// Query existing guestbook entries.
60
62
$ results = $ db ->query ('SELECT * from entries ' );
61
63
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
+ //
62
68
# [END gae_cloudsql_example]
63
69
?>
64
70
You can’t perform that action at this time.
0 commit comments