Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use globally-defined ADODB_FETCH_MODE if it is false on the object in getAssoc #927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

letynsoft
Copy link

In my Ubuntu 22.10, I've come to an issue with the getAssoc function.
It was a version 5.21.4, but i believe the current implementation did not fix the underlying issue.

I think that in case the connection fetchMode is false, the global $ADODB_FETCH_MODE should be used instead.

@dregad
Copy link
Member

dregad commented Apr 16, 2023

@mnewnham do you remember the reason for using the Connection's fetch mode here, instead of the RecordSet's ?

I'm thinking that since we now have $adodbFetchMode defined in the Recordset, it would make sense to use that and not rely on the Connection, what do you think ?

See also #958, which cleans up initialization of RecordSet $fetchMode.

@dregad
Copy link
Member

dregad commented Apr 24, 2023

@mnewnham it would be great to have your feedback on this.

@mnewnham
Copy link
Contributor

If I remember correctly:
We use the fetchMode in getAssoc() rather than ADODB_FETCH_MODE because we use this method chained from other internals. example

  1. We start with a procedure that sets the $ADODB_FETCH_MODE to FETCH_ASSOC
  2. We then call an internal function MetaColumns(). This requires that the fetch mode is FETCH_NUM
  3. We save the current fetch mode in the MetaColumns method and switch $fetchMode to FETCH_NUM
  4. We execute getAssoc with the fetchMode of FETCH_NUM even though ADODB_FETCH_MODE is FETCH_ASSOC
  5. We return the results of getAssoc to MetaColumns, process it out, then switch the fetchMode back to FETCH_ASSOC

We have also talked about deprecating globals like ADODB_FETCH_MODE and bringing them into class variables because it prevents us controlling 2 simultaneous connections properly. For example if I open an Oracle connection in FETCH_NUM mode and a MySQL connection in FETCH_ASSOC mode, I have to reset the global before every call to the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants