Oracle -> oci_define_by_name in sqlsrv [php]

问题描述 投票:0回答:1

在SQLSRV中,ORACLE扩展的以下函数的等价物是什么?oci_define_by_name?

文件。https:/www.php.netmanualfrfunction.oci-define-by-name.php

我如何在 sqlsrv 中翻译这个 (oracle php) 函数?

 if ( isset( $_GET['Refdti'] ) ) 
  {
    $Refdti  = $_GET['Refdti'];
  }

  $ora_stmt = oci_parse($ora_connect, $request);
  if ( ! $ora_stmt ) 
  {
    $retour = array('success' => false, 'msg' => 'Problem oci_parse requete='.$request);
    oci_close($ora_connect);
    return;
  }
  oci_define_by_name($ora_stmt, 'REFDTI'   , $refdti);
php sql-server oracle odbc sqlsrv
1个回答
1
投票

我不认为PHP Driver for SQL Server (sqlsrv 扩展)支持完全等同的 oci_define_by_name() 函数(将一个PHP变量与一个列关联起来,以便查询获取)。可能合适的方法是使用 sqlsrv_fetch_array() 函数来检索下一行数据。注意,你可以使用 sqlsrv_query() 来准备和执行语句,因为(正如在 文件)这 函数非常适合一次性查询,除非特殊情况,否则应该是执行查询的默认选择。.

甲骨文的例子。

<?php
if (isset($_GET['Refdti'])) {
    $Refdti = $_GET['Refdti'];
}

...
$ora_stmt = oci_parse($ora_connect, $request);
if (!$ora_stmt ) {
    $retour = array('success' => false, 'msg' => 'Problem oci_parse requete='.$request);
    oci_close($ora_connect);
    return;
}
oci_define_by_name($ora_stmt, 'REFDTI' , $refdti);
oci_execute($stid);

while (oci_fetch($ora_stmt)) {
    echo $refdti."\n";
}  

...
?>  

SQL Server的例子:

<?php
if (isset($_GET['Refdti'])) {
    $Refdti = $_GET['Refdti'];
}

...
$ms_stmt = sqlsrv_query($ms_connect, $request);
if ($ms_stmt === false ) {
    $retour = array('success' => false, 'msg' => 'Problem sqlsrv_query requete='.$request);
    sqlsrv_close($ms_connect);
    return;
}

while ($row = sqlsrv_fetch_array($ms_stmt, SQLSRV_FETCH_ASSOC)) {
    echo $row["REFDTI"]."\n";
}

...
?>  
© www.soinside.com 2019 - 2024. All rights reserved.