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

Detect transport type from database connection passed in #133

Open
alanseiden opened this issue Oct 16, 2020 · 1 comment
Open

Detect transport type from database connection passed in #133

alanseiden opened this issue Oct 16, 2020 · 1 comment
Assignees

Comments

@alanseiden
Copy link
Collaborator

When instantiating the toolkit, users who pass in a database connection that is not ibm_db2 must either specify the transport type in parameter 4 or change toolkit.ini. It's extra work and makes it hard to remember what parameters need to be passed. The toolkit could, instead, automatically detect the transport type when a database connection is passed as parameter 1.
Here is the constructor:

return new Toolkit($databaseNameOrResource, $userOrI5NamingFlag, $password, $transportType, $isPersistent);

  • ibm_db2 and odbc database connections could be detected with get_resource_type(). The result will be DB2 Connection, DB2 Persistent Connection, odbc link, or odbc link persistent.
  • PDO database connections could be detected with $databaseNameOrResource instanceof PDO.
@alanseiden alanseiden self-assigned this Oct 16, 2020
@NattyNarwhal
Copy link
Contributor

notes:

  • php 8 changes a lot of resources to be classes instead
  • the entire ctor should be less of a god function. logically, using an existing resource vs. creating one would be a good way to split it
  • perhaps it could be even (forgive me for this) a factory with named ctors instead

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

No branches or pull requests

2 participants