我最近负责维护用6种左右语言(HTML,javascript,php,java,postgres,python ...)编写的几乎完成的网站和后端。我对其中一些很好,但对其他一些(PHP,JavaScript)则不满意。
我无法使用php将网站连接到postgres数据库。我已经找到并修改了一个名为dbconn.php的文件(大概负责连接数据库),当前看起来像这样:
void MainGame::RenderTestUI()
{
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLSLProgram *ActiveShader = nullptr;
ActiveShader = &ColorShader;
ActiveShader->Use();
GLint Location1 = ActiveShader->GetUniformLocation("cam");
glm::mat4 tmp = Camera.GetCameraMatrix();
glUniformMatrix4fv(Location1, 1, GL_FALSE, &tmp[0][0]);
glActiveTexture(GL_TEXTURE0);
GLint Location2 = ActiveShader->GetUniformLocation("basic");
glUniform1f(Location2, 0);
glBindTexture(GL_TEXTURE_2D, GameTextures.ID);
CurrentBoundTexture = GameTextures.ID;
RenderingBatch.StartAddingVerticies();
this->GameMap.TileList[1].FillSixVerticies(RenderingBatch.VertexListPtr, 0, 0);
RenderingBatch.VertexCount += 6;
for (int i = 0; i < 6; i++)
RenderingBatch.VertexListPtr[i].z = -10; // first face
this->GameMap.TileList[2].FillSixVerticies(&RenderingBatch.VertexListPtr[RenderingBatch.VertexCount], 8, 8);
RenderingBatch.VertexCount += 6;
for (int i = 0; i < 6; i++)
RenderingBatch.VertexListPtr[i+6].z = -25; // second face
RenderingBatch.EndAddingVerticies();
RenderingBatch.CreateVBO();
RenderingBatch.Render();
ActiveShader->Unuse();
// swap buffers
SDL_GL_SwapWindow(GameWindow);
}
这不会在网站和数据库之间建立连接。但是,我可以通过
从终端中的相同IP地址登录数据库。psql -h redshift-cluster-merp.something.region.redshift.amazonaws.com -U awsuser -p 5430 -d merpdev
我还可以通过具有类似参数的JDBC连接。文件<?php
$host = "redshift-cluster-merp.something.region.redshift.amazonaws.com";
$port = 5430;
$user = "awsuser";
$pass = "myfancypassword";
$dbName = "merpdev";
$dsn = "pgsql:host=$host;dbname=$dbName;port=$port;";
$pdo = new PDO($dsn, $user, $pass);
?>
是否正确或我丢失了什么?
我想象带有dbconn.php
和/或$dsn
的行可能存在语法错误。