设置 - 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
我知道连接正常。在用 Postgres 交换 MySQL 函数后,一些查询正在工作 - 我知道这一点,因为我可以看到数据填充。我还必须进行一些调整才能使查询正常工作。
复制字段的查询具有有效的 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'];
}
}
MMTTMM