将 ODBC SQL 查询转换为使用准备好的语句 [英] Convert ODBC SQL query to use prepared statements

查看:59
本文介绍了将 ODBC SQL 查询转换为使用准备好的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ODBC (Win32) 连接到我们的 Pervasive SQL 数据库.我有需要插入 SQL 查询并稍后提取各个行的 post 变量.

I'm using ODBC (Win32) to connect to our Pervasive SQL database. I have post variables that I need to insert into SQL queries and later extract individual rows.

以下是我目前所拥有但由于某种原因无法正常工作的示例:

Here's an example of what I have so far but isn't working for some reason:

$sql_bin2=odbc_prepare($conn,'SELECT TOP 1 icitemo.value FROM icitemo WHERE icitemo.itemno = ? AND icitemo.optfield = ?');

$result_bin2=odbc_execute($sql_bin2, array($barcode, $var_bin2));

while (odbc_fetch_row($result_bin2)){$bin2=odbc_result($result_bin2,"VALUE");}

没有返回任何东西.我在这里做错了什么?

Nothing gets returned. What am I doing wrong here?

推荐答案

以下是这个问题的答案:

Here's the answer to this:

$sql_bin2 = odbc_prepare($conn, 'SELECT TOP 1 icitemo.value FROM icitemo WHERE icitemo.itemno = ? AND icitemo.optfield = ?');

odbc_execute($sql_bin2, array($barcode, $var_bin2));

if ($sql_bin2) {
    $bin2 = odbc_result($sql_bin2,"VALUE"); }

这篇关于将 ODBC SQL 查询转换为使用准备好的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆