How does PHP ODBC convert a result set to an array?

problem description

how does the PHP ODBC connection SQL server convert the result set to an array?

related codes

/ / Please paste the code text below (do not replace the code with pictures)
$query= "SELECT * from tblWeight where LISTID="$listid" and DateDiff (dd,LISTTIME,getdate ()) < = 2"; $result=odbc_exec ($link,$query);
$worklist = array ();
while (odbc_fetch_row ($result)) {

)

}

what result do you expect?

if you want to use the array $worklist to receive the result set after the query, how to write it in while?

Php
Dec.02,2021

it is recommended that you switch to odbc_fetch_array ($result)

odbc-fetch-array

can also

while (odbc_fetch_row($result)) {
    $arr = array(
        $fieldNameA => odbc_result($result, $fieldNameA)
        $fieldNameB => odbc_result($result, $fieldNameB)
        ...
        $fieldNameN => odbc_result($result, $fieldNameN)
    );
}

odbc-fetch-row
After odbc_fetch_row () is called, the fields of that row can be accessed with odbc_result ()
odbc-result

mixed odbc_result (resource $result_id, mixed $field)
$field : The field name being retrieved. It can either be an integer containing the column number of the field you want; or it can be a string containing the name of the field.
Menu