php - Reusing Ajax Established Database Connection
Two Files involved:
index.php (html markup, db connection and class object)
getajax.php (db connection, sql + response code)
Need to see how can I eliminate the duplicate connection details off the getajax file and reuse the existing class connection function or contruct on index.
Already using mysql_pconnect for connection reuse on the getajax file and index.
Should I create an extended class for "getajax" so it extends primary object?
Trying to avoid overkill on DB when lots of calls are made to sql.
Simply using pconnect is sufficient. As noted in the PHP documentation about persistent database connections:
That is, simply using pconnect tells PHP to use an existing connection if it's available. Whether or not it was the same connection used by the first PHP call is unimportant.
Make sure you read that PHP manual page - there are some important caveats.