odbc_result

分享于2022年07月17日 intersystems-cache odbc php 问答
【问题标题】:odbc_result():字段索引大于字段数?(odbc_result(): Field index is larger than the number of fields?)
【发布时间】:2022-06-23 17:39:19
【问题描述】:

如何解决此错误?我希望获得结果第一行的关联数组,而不必命名所有列。

PHP 警告:odbc_result(): 字段索引大于 字段

    $sql = "sql query with 14 columns";
    $result = odbc_do($link, $sql) or trigger_error("query failed ".odbc_errormsg(), E_USER_ERROR);
    $details = odbc_fetch_array($result,0);
    return $details;


【解决方案1】:

尝试将 0 替换为 1

odbc_fetch_array($result,0);

odbc_fetch_array($result,1);