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

socket unix not allowed in constructor #3

Open
jferran95 opened this issue Mar 17, 2019 · 3 comments
Open

socket unix not allowed in constructor #3

jferran95 opened this issue Mar 17, 2019 · 3 comments

Comments

@jferran95
Copy link

I do not see a way to open a connection using a socket (unix).
It seems the constructor is closed to using hostname and port.
It is interesting to respect the use of a socket (allowed in mysqli).

You can also think changing the design to allow use of an externally created connection.
The component can delegate unto others, like an external framework, to host the top level configuration, handling of a connection-pool, redundancy or whatever new features appear.

So it is better suited for integration with others projects. To use this component as a thin abstraction layer on top of mysqli (connection).

@D-Marc1
Copy link
Owner

D-Marc1 commented Mar 17, 2019

Hey, thanks for the suggestion, @jferran95. I can definitely add socket as an option to the constructor. I think it might be better to make it into a key-value array now.

Can you please clarify your second point for what you're looking for in terms of design change?

@jferran95
Copy link
Author

Still testing. Need to evaluate first. But before that I saw a relevant issue with the design. This component takes the responsibility to open a connection. That is a huge no thanks. That is a sensitive feature. Due to security it is nice to hide. Another black box [component] will provide a connection. Dealing with user authentication, connection persitence, pooling, load balancing, targeting multiple databases (batch processes). This component in order to be simple, must give up on that responsibility.

For instance I modified it just for testing purposes (evaluation):

	public function __construct( $input_mysqli ) {
	    //mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
	    $this->mysqli = $input_mysqli;
	    $this->mysqli->set_charset( 'utf8mb4' );
	}

So a php-framework provides the connection. And this component works on top, as a mere wrapper.

Will have more insight about the design after using it for days.

@D-Marc1
Copy link
Owner

D-Marc1 commented Mar 19, 2019

Ah, ok, I understand you. Ya, I agree it would be better to use dependency injection. I'd be happy to make this change.

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

No branches or pull requests

2 participants