<?php
//use Google_Client;
echo "<table style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
//$client = new Google_Client();
//$client->setAuthConfig('client.json');
//$client->setLoginHint('xpserv.amity@gmail.com');
$servername = "127.0.0.1";
$username = $_POST["username"];
$password = $_POST["password"];
//$mydb = "xp_database";
//$port="3308"; inner-period-262304:asia-east2:xpserve-sqlinstance
//CLOUDSQL_DSN: "mysql:dbname=DATABASE;unix_socket=/cloudsql/inner-period-262304:asia-east2:xpserve-sqlinstance"
$dsn = 'mysql:dbname=xp_database;unix_socket=/cloudsql/inner-period-262304:asia-east2:xpserve-sqlinstance';
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
try
{
// Coonection establishment
$conn = new PDO($dsn, $username, $password, $options);
//$conn = new PDO($dsn, $username);
//echo $conn;
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT custname FROM cust_master_table");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
echo "</table>";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
echo "hello db9";
?>
我在一个项目中创建了一个sql实例。我的应用程序在gcp中的另一个项目中。该应用程序是一个PHP应用程序。 Iam无法从网站检索记录。我在日志中收到以下消息
nginx:[警告]仅当主进程使用超级用户特权运行时,“用户”指令才有意义,在/tmp/google-config/nginx.conf:3
中将其忽略请告诉我该怎么做。