How to connect DB from webroot's folder

Dear All,
please, could someone explain to me how could I from the folder webroot connect to the DB?

I have tried without success:
image

Or maybe I have another choice? So, what I am doing and why: I have a VIEW that is very slow because load a lot of data. What I did is: I created a horizontal menu and when you click at the button I use AJAX to load the needed info. The files used with AJAX are located in webroot’s folder.

Thank you for your attention and help,

Why do you need to connect from webroot?

Better put your code at the end of config/bootstrap.php or in Application::bootstrap() method

1 Like

I don’t need to connect from webroot. I got the advice that I could do it with ‘Action Controller’.

image

I am trying to figure out how exactly should I do that.

Thank you.

I think you’re in over your head. Try going through the CakePHP tutorials first to understand what controllers are and how they work. Then you’ll understand the controllers contain actions which are mapped to the URL. This is one of the most basic cake concepts.
Then meditate on: why do you want to open a database if you’re trying to serve data in files? What does that have to do with a database?