【问题标题】:Migrate PHP/Mysql to PHP/Oracle将 PHP/Mysql 迁移到 PHP/Oracle
【发布时间】:2015-08-20 07:50:51
【问题描述】:

如何将我的 PHP/Mysql 代码转换为 PHP/Oracle。 这是我的代码。

$query = "SELECT name FROM employee WHERE name = '".$userName."' and email = '".$userMobile."' and salary = '".$userSalary."' and deductions = '".$userDeductions."'";
$sql = mysql_query($query);
$recResult = mysql_fetch_array($sql);
$existName = $recResult["name"];
if($existName=="") {
$insertTable= mysql_query("insert into employee (name, email, salary, deductions) values('".$userName."', '".$userMobile."', '".$userSalary."', '".$userDeductions."');");

【问题讨论】:

  • 需要转换什么?对我来说看起来像标准 SQL。但是,如果 salarydeductions 是数字类型,则需要删除值周围的引号。
  • 即使是数字 oracle 也不介意用引号括起来。但是,如果 $userDeductions 中的值有任何格式标记,情况就会不同

标签: php


【解决方案1】:

PDO 可能是一种解决方案。但是,如果您想继续现有的,那么您遇到的问题是什么?对我来说似乎是简单的语法。但由于 PDO 是一种非常好的/DB 独立方式,因此我建议您,您可以在 http://php.net/manual/en/ref.pdo-oci.php 找到一个示例。 顺便说一句,这是我可以做的一件粗略的事情(没有得到测试),请检查一下。更多信息请访问selecting record from oracle

$query = "SELECT name FROM employee WHERE name = '".$userName."' and email = '".$userMobile."' and salary = '".$userSalary."' and deductions = '".$userDeductions."'";
$sql = oci_parse($conn,$query);
oci_execute($sql);
$existName = oci_result($sql, 1);
if($existName=="") {
#...
}

【讨论】:

    猜你喜欢
    • 2012-09-14
    • 2012-12-13
    • 2011-08-25
    • 2011-02-28
    • 2014-09-05
    • 2013-12-24
    • 1970-01-01
    • 2010-09-24
    • 1970-01-01
    相关资源
    最近更新 更多