ohad Posted June 15, 2020 Share Posted June 15, 2020 Hi all, I have a query that return data into the array $row with values, but $id from the first line of the while stay null. Why? $con = oci_connect("xxx", "xxx", "xxx"); $query = "SELECT id, name from table_web WHERE record_module='AA' and parent_id='".$parentId."'"; $stid=oci_parse($con, $query); oci_execute($stid); while($value = oci_fetch_assoc($stid)) { $id = $value['id']; $row[$id]['id'] = $value['id']; $row[$id]['name'] = $value['name']; } return $row; Quote Link to comment https://forums.phpfreaks.com/topic/310946-question-regrding-fetch_assoc/ Share on other sites More sharing options...
gw1500se Posted June 15, 2020 Share Posted June 15, 2020 oci_fetch_assoc returns an array of all the rows returned by the query. Call it once then put $value in a 'for' loop to process each row. $rows=oci_fetch_assoc($stid); foreach ($rows as $row) { . . . } Quote Link to comment https://forums.phpfreaks.com/topic/310946-question-regrding-fetch_assoc/#findComment-1578927 Share on other sites More sharing options...
ohad Posted June 15, 2020 Author Share Posted June 15, 2020 This still leaves $id from this $id = $value['id'] line null Quote Link to comment https://forums.phpfreaks.com/topic/310946-question-regrding-fetch_assoc/#findComment-1578928 Share on other sites More sharing options...
requinix Posted June 15, 2020 Share Posted June 15, 2020 According to the documentation, oci_fetch_assoc() returns one row of data. Quote Link to comment https://forums.phpfreaks.com/topic/310946-question-regrding-fetch_assoc/#findComment-1578930 Share on other sites More sharing options...
ohad Posted June 15, 2020 Author Share Posted June 15, 2020 OK problem solved The issue was $id = $value['ID']; once i changed names of fields to capital letters, all works fine Quote Link to comment https://forums.phpfreaks.com/topic/310946-question-regrding-fetch_assoc/#findComment-1578931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.