【问题标题】:Switch mysql statements to postgresql将mysql语句切换到postgresql
【发布时间】:2015-11-21 03:01:48
【问题描述】:

我是 php 和 postgres sql 的新手。 我正在尝试从 mysql 切换到 postgresql。

我是在 mysql 上做的:

$adresse=mysql_escape_string($_POST['mail_user']);
if(isset($_POST['mail_user']))
{
   $stmt = mysqli_prepare($con, 'SELECT email FROM newusers2 WHERE email =?');
           mysqli_stmt_bind_param($stmt, "s", $adresse);
           mysqli_stmt_execute($stmt);
           mysqli_stmt_store_result($stmt);
  $nb = mysqli_stmt_num_rows($stmt);
               if ($nb>=1) {
                            //echo "address already exist"
                            $nb == 0;
                            } 
               else {
                            //echo "address added"
                            $nb == 0;
                     }
}

我想听听您对 Postgresql 中的等效项的建议。

$check = "SELECT email FROM newusers2 WHERE email = $2";
$stmt = pg_query_params($con,$check,array($adresse));
$nb = pg_numrows($stmt);

非常感谢您的帮助和所有建议。

谢谢

【问题讨论】:

  • a) 你有什么问题 b) 2 美元? 2?
  • 对我不使用 PHP 的人来说看起来不错,除了 $2 应该是 $1 并且您忘记检查错误(在这两种情况下)

标签: php mysql postgresql


【解决方案1】:

查看 PHP Pear DB 模块,它与数据库无关且易于使用。或者使用更新的模块 MDB2。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多