I am developing an application in which I am using AJAX and PHP. Lets say from my initial.php files I am making request via AJAX to ajaxResponse.php file where I execute some code and interact with MySQL .Since I am handling with dtabase I am using my written Db class and on the top of my ajaxResponse.php I have to write
require_once("includes/Db.php"); $db=new Db();
in order to use the methods of the class. I can send request to that files 1000 and more times (since I am building a livechat) and in all times it will do that require_once and $db=... . Do you think thats the best solution ? What disadvantages it has ? And what other methods you suggest to sort that out So i'll require only once or maybe anything else that you will recommend .
Thank you in advance for your efforts !!!