设置 - PHP 7 应用程序。- Postgres 在 Heroku Hobby v11.x 上 - MySQL 版本是 v5.5.56 和协议 10 - 我对 PHP 不太了解 - 我对低级 Postgres 转换没有深入了解。
我使用 pgloader 从 MySQL 迁移到 Postgres。
pgloader --dry-run --with 'create indexes' --with 'create indexes' --with 'foreign keys' --with 'downcase identifiers' --with 'create tables' --with 'include drop' mysql://<<hidden>>@us-cdbr-iron-east-03.cleardb.net/heroku_509e1e230baf4be postgres://<<hidden>>@ec2-23-21-177-102.compute-1.amazonaws.com:5432/dflfjbhhq18cav?sslmode=require
我知道连接正常。在将 MySQL 函数与 Postgres 交换后,一些查询正在工作 - 我知道这一点,因为我可以看到数据填充。我还必须进行一些调整才能使查询正常工作。
复制字段的查询具有有效的 SQL 语句,但出现以下错误。我知道这个查询很好,因为我已经将它回显并粘贴到我的 Navicat SQL 窗口中,它会产生正确的结果。
pg_query(): Query failed: ERROR: permission denied for table campaigns
DB 用户似乎拥有访问campaigns
表并获得所需内容的所有适当权限。
我继续寻找另一个非常奇怪的问题。
无论我使用什么来尝试使用有效的 SQL 语句使用 PHP 运行查询,我都没有得到任何数据。
-pg_pquery -pg_fetch_array -pg_query_params -pg_fetch_array
请参阅下面的代码示例。
//Get the existing number of quota_deducted
$q = 'SELECT app, quota_deducted FROM campaigns WHERE id = '.$campaign_id;
$r = pg_query($mysqli, $q);
if ($r)
{
while($row = pg_fetch_array($r))
{
$app = $row['app'];
$current_quota_deducted = $row['quota_deducted']=='' ? 0 : $row['quota_deducted'];
}
//Check if monthly quota needs to be updated
$q2 = 'SELECT allocated_quota, current_quota FROM apps WHERE id = '.$app;
$r2 = pg_query($mysqli, $q2);
if($r2)
{
while($row2 = pg_fetch_array($r2))
{
$allocated_quota = $row2['allocated_quota'];
$current_quota = $row2['current_quota'];
}
}
$updated_quota = $current_quota - $current_quota_deducted;
//Update quota if a monthly limit was set
if($allocated_quota!=-1)
{
//if so, update quota
$q3 = 'UPDATE apps SET current_quota = '.$updated_quota.' WHERE id = '.$app;
pg_query($mysqli, $q3);
}
}
我在 apache2 终端窗口的尾随日志中看到错误,但在数据库 pgAdmin 上看不到任何实际连接或活动。
Heroku DB 上的日志似乎也没有出现?不确定这是否是因为它只是一个爱好。
我已经检查了所有明显的东西,比如确保我们连接到正确的数据库等等。
使用 Navicate 时,我在尝试调用表 DESIGN 函数时遇到了以前从未见过的错误。我收到以下错误。不确定这是否对上述问题有影响。我能够测试其他相同版本的 Postgres,发现下面的这个错误不存在。因此,也许 pgloader 正在创建一些无法解决的低级别问题。
ERROR: Column "proisagg" doe snot exist
LINE 1: ...e JOIN pg_language lng ON lng.oid=p.prolang WHERE proisagg = ..
HINT: Perhaps you meant to reference the column "p.prolang".
这是我们尝试运行的查询。这在 Navicat 中确实有效。
INSERT INTO campaigns (userid, app, from_name, from_email, reply_to, title, label, plain_text, html_text, query_string, bounce_setup, complaint_setup, wysiwyg, opens_tracking, links_tracking) VALUES (2, 152, 'Person Name', 'campaignsupport@company.com', 'campaignsupport@company.com', 'Test', '', 'Test plain text.', 'asdf', '', 0, 0, 1, 1, 1)
或者
INSERT INTO public.campaigns (userid, app, from_name, from_email, reply_to, title, label, plain_text, html_text, query_string, bounce_setup, complaint_setup, wysiwyg, opens_tracking, links_tracking) VALUES (2, 152, 'Person Name', 'campaignsupport@company.com', 'campaignsupport@company.com', 'Test', '', 'Test plain text.', 'asdf', '', 0, 0, 1, 1, 1)
在过去的 20 个小时里,我一直在研究这个问题,我很难过任何帮助或想法都会得到很大的帮助。
温馨问候,
凯西哈弗诺