From a2d29cc28dc47208dd1b9e8a9286c1d35c1746b0 Mon Sep 17 00:00:00 2001 From: "Mr. E23" Date: Mon, 24 Nov 2003 19:33:26 +0000 Subject: [PATCH] Added wfUnbufferedQuery() --- includes/DatabaseFunctions.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/DatabaseFunctions.php b/includes/DatabaseFunctions.php index e6bc40b6a5..a0f572a75b 100644 --- a/includes/DatabaseFunctions.php +++ b/includes/DatabaseFunctions.php @@ -8,6 +8,8 @@ define( "DB_LAST", -3 ); $wgLastDatabaseQuery = ""; +/* private */ $wgBufferSQLResults = true; + function wfGetDB( $altuser = "", $altpassword = "", $altserver = "", $altdb = "" ) { global $wgDBserver, $wgDBuser, $wgDBpassword; @@ -94,9 +96,8 @@ function wfEmergencyAbort( $msg = "" ) { # Replication is not actually implemented just yet function wfQuery( $sql, $db, $fname = "" ) { - global $wgLastDatabaseQuery, $wgOut, $wgDebugDumpSql; + global $wgLastDatabaseQuery, $wgOut, $wgDebugDumpSql, $wgBufferSQLResults; global $wgProfiling; - if ( $wgProfiling ) { # wfGeneralizeSQL will probably cut down the query to reasonable # logging size most of the time. The substr is really just a sanity check. @@ -119,7 +120,11 @@ function wfQuery( $sql, $db, $fname = "" ) } $conn = wfGetDB(); - $ret = mysql_query( $sql, $conn ); + if( $wgBufferSQLResults ) { + $ret = mysql_query( $sql, $conn ); + } else { + $ret = mysql_unbuffered_query( $sql, $conn ); + } if ( false === $ret ) { $wgOut->databaseError( $fname ); @@ -132,6 +137,17 @@ function wfQuery( $sql, $db, $fname = "" ) return $ret; } +function wfUnbufferedQuery( $sql, $db, $fname = "" ){ + global $wgBufferSQLResults; + $oldstate = $wgBufferSQLResults; + + $wgBufferSQLResults = true; + $res = wfQuery($sql, $db, $fname); + + $wgBufferSQLResults = $oldstate; + return $res; +} + function wfFreeResult( $res ) { mysql_free_result( $res ); } function wfFetchObject( $res ) { return mysql_fetch_object( $res ); } function wfNumRows( $res ) { return mysql_num_rows( $res ); } -- 2.20.1