I
I
Ilya Bobkov2015-11-01 10:56:35
PHP
Ilya Bobkov, 2015-11-01 10:56:35

Where should mysqli object be created?

Всем привет! Пишу сейчас обращение к БД через ajax.
     $.ajax
     ({
       url:  "server.php",
       data: {   func:"RegUser", password:$("#reg_password").val(),email:$("#reg_email").val() },
       success: function( data )
       {
  		//  ответ
       }
});


Server:
if ( $_GET["func"] == "RegUser" )
{
}

Now the question is: Where should I include mysqli object creation? In the Get request or outside of it globally? And will the object be saved the next time it is accessed. What's the best way to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Koryukov, 2015-11-01
@MadridianFox

Each ajax request, as well as the opening of each page, re-runs the php script on the server.
Therefore, from the point of view of saving the object between ajax requests, there is no difference - the object will always be created anew.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question