Page 1 of 1

Do sqlValue and sql functions close/reuse connections?

Posted: 2020-05-19 09:24
by onoehring
Hi,

I got an error from the MySQL Server (on 1&1) that "user .... already has more than max_user_connections active connections".
I make use of AppGini's SQL functions sql and sqlValue, so I am wondering, if they close their connection after the result has been received.
Or - does AG create a single connection an reuses it?

I am happy about any other ideas how to solve such a problem.

Olaf

Re: Do sqlValue and sql functions close/reuse connections?

Posted: 2020-05-19 14:05
by D Oliveira
onoehring wrote:
2020-05-19 09:24
Hi,

I got an error from the MySQL Server (on 1&1) that "user .... already has more than max_user_connections active connections".
I make use of AppGini's SQL functions sql and sqlValue, so I am wondering, if they close their connection after the result has been received.
Or - does AG create a single connection an reuses it?

I am happy about any other ideas how to solve such a problem.

Olaf

personally i rely on msqli

ajax-template.php

Code: Select all


<?php

	$currDir = dirname(__FILE__) . '/..'; // inside hooks folder, remove the concatenation if placed in main app folder.
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");

	$con = mysqli_connect($dbServer, $dbUsername, $dbPassword);
	mysqli_select_db($con,$dbDatabase);

	$mi = getMemberInfo();

	$ajax_var = makesafe($_REQUEST['ajax_var']);
	
	$query = mysqli_query($con,"select * from policies where ID= '{$ajax_var}'");
	$table_ajax = mysqli_fetch_array($query);

    	echo json_encode($table_ajax);

?>


Re: Do sqlValue and sql functions close/reuse connections?

Posted: 2020-05-20 05:20
by onoehring
Hi,

thank you, I will try your suggestion.
Olaf

Re: Do sqlValue and sql functions close/reuse connections?

Posted: 2020-11-06 12:07
by onoehring
Hi,

just wondering if anyone has already used the db_close function which can be found in the /db.php file.

Code: Select all

function db_close($link = NULL) {
		db_link(false); /* close db link */
		switch(DATABASE) {
			case 'mysql':
				return mysql_close($link);
			case 'mysqli':
				return mysqli_close($link);
		}
	}
I am wondering if it's worth, putting the db_close in the end of my own file(s) - or maybe even into the /hooks/footer-extras.php ??

This should probably close the db connection. Of course, it would cost some time to reopen it again when a page is refreshed / loaded but at least this would not block other users from using the application because they have to wait for a db connection to automatically close.

Olaf