Do sqlValue and sql functions close/reuse connections?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1158
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Do sqlValue and sql functions close/reuse connections?

Post by onoehring » 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

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

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

Post by D Oliveira » 2020-05-19 14:05

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);

?>



User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1158
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2020-11-06 12:07

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

Post Reply