mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
functions.inc.php
- create_page_browser(): revert r1387 and... - db_query(): ...replace it with the correct fix ;-) (avoid mysqli reconnects) The problem was that db_query() used is_resource() to check if we already have a database connection, but a mysqli connection is an object, not a resource. This resulted in a new database connection for each query. Therefore mysqli "forgot" the value of SET @row before executing the following SELECT query (which used a new mysqli connection). The fix is to also check with is_object() to avoid mysqli reconnects. git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1388 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
182c67e1cd
commit
954b18c169
@ -500,10 +500,11 @@ function create_page_browser($idxfield, $querypart) {
|
|||||||
# get labels for relevant rows (first and last of each page)
|
# get labels for relevant rows (first and last of each page)
|
||||||
$page_size_zerobase = $page_size - 1;
|
$page_size_zerobase = $page_size - 1;
|
||||||
$query = "
|
$query = "
|
||||||
SELECT *, MOD(idx.row, $page_size) FROM (
|
SELECT * FROM (
|
||||||
SELECT $idxfield AS label, @row := @row + 1 AS row $querypart
|
SELECT $idxfield AS label, @row := @row + 1 AS row $querypart
|
||||||
) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results
|
) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results
|
||||||
";
|
";
|
||||||
|
|
||||||
if ('pgsql'==$CONF['database_type']) {
|
if ('pgsql'==$CONF['database_type']) {
|
||||||
$query = "
|
$query = "
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
@ -1517,7 +1518,8 @@ function db_query ($query, $ignore_errors = 0) {
|
|||||||
$error_text = "";
|
$error_text = "";
|
||||||
if ($ignore_errors) $DEBUG_TEXT = "";
|
if ($ignore_errors) $DEBUG_TEXT = "";
|
||||||
|
|
||||||
if (!is_resource($link)) $link = db_connect ();
|
# mysql and pgsql $link are resources, mysqli $link is an object
|
||||||
|
if (! (is_resource($link) || is_object($link) ) ) $link = db_connect ();
|
||||||
|
|
||||||
if ($CONF['database_type'] == "mysql") $result = @mysql_query ($query, $link)
|
if ($CONF['database_type'] == "mysql") $result = @mysql_query ($query, $link)
|
||||||
or $error_text = "<p />DEBUG INFORMATION:<br />Invalid query ($query) : " . mysql_error($link) . "$DEBUG_TEXT";
|
or $error_text = "<p />DEBUG INFORMATION:<br />Invalid query ($query) : " . mysql_error($link) . "$DEBUG_TEXT";
|
||||||
|
Loading…
Reference in New Issue
Block a user