From 69251564fb724b50db7282c3795863197cc9da40 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Fri, 20 Aug 2004 12:47:12 +0000 Subject: [PATCH] database abstraction --- includes/LinksUpdate.php | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 50afb971ca..435d610c34 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -53,20 +53,15 @@ class LinksUpdate { # Do the insertion $sql = ""; if ( 0 != count( $add ) ) { - # The link cache was constructed without FOR UPDATE, so there may be collisions - # Ignoring for now, I'm not sure if that causes problems or not, but I'm fairly - # sure it's better than without IGNORE - $sql = "INSERT IGNORE INTO $links (l_from,l_to) VALUES "; - $first = true; - foreach( $add as $lt => $lid ) { - if ( ! $first ) { $sql .= ","; } - $first = false; - - $sql .= "({$this->mId},{$lid})"; - } - } - if ( "" != $sql ) { - $dbw->query( $sql, $fname ); + $arr=array(); + foreach($add as $lt=>$lid) + array_push($arr,array( + 'l_from'=>$this->mId, + 'l_to'=>$lid)); + # The link cache was constructed without FOR UPDATE, so there may be collisions + # Ignoring for now, I'm not sure if that causes problems or not, but I'm fairly + # sure it's better than without IGNORE + $dbw->insertArray($links,$arr,array('IGNORE')); } #------------------------------------------------------------------------------ @@ -99,17 +94,14 @@ class LinksUpdate { # Do additions $sql = ""; if ( 0 != count ( $add ) ) { - $sql = "INSERT IGNORE INTO $brokenlinks (bl_from,bl_to) VALUES "; - $first = true; + $arr=array(); foreach( $add as $blt ) { $blt = $dbw->strencode( $blt ); - if ( ! $first ) { $sql .= ","; } - $first = false; - - $sql .= "({$this->mId},'{$blt}')"; + array_push($arr,array( + 'bl_from'=>$this->mId, + 'bl_to'=>$blt)); } - } - if ( "" != $sql ) { + $dbw->insertArray($brokenlinks,$arr,array('IGNORE')); $dbw->query( $sql, $fname ); } -- 2.20.1