A
A
Artem2015-11-03 10:15:56
PHP
Artem, 2015-11-03 10:15:56

How to organize work with a database in a library?

Hi all.
There is a custom library that I made, all of its methods interact with the database, but the configs for connecting to the database and tables are in a separate file, how would it be more correct to organize work with the database in order to get rid of the config file, but not tire the user by entering these data to the class constructor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
angru, 2015-11-03
@angru

Support both. Let the user choose which one he likes best.

A
Alexander Kubintsev, 2015-11-03
@akubintsev

Write a factory that will take data from the config and pass it to the constructor of your library.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question