From: Cameron Ball Date: Tue, 24 Feb 2015 01:28:40 +0000 (+0800) Subject: #9 Should be fixed X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=d9164ea8e821b5d91516462c66b99861efd91c15;p=rock.divinelegy.git #9 Should be fixed --- diff --git a/DataAccess/DataMapper/DataMapper.php b/DataAccess/DataMapper/DataMapper.php index a4e474c..4b69b13 100644 --- a/DataAccess/DataMapper/DataMapper.php +++ b/DataAccess/DataMapper/DataMapper.php @@ -147,16 +147,17 @@ class DataMapper implements IDataMapper $query = substr($query, 0, -2); $query .= sprintf(' WHERE id=%u', $info['id']); } else { + //The files table has hash and filename as a unique index. + //Some packs share the same banner for every file, and we only + //ever pull them out by hash. So this on duplicate thing saves + //having loads of entries $query = sprintf('INSERT INTO %s (%s) VALUES (%s)', $info['table'], implode(', ', array_keys($info['columns'])), - implode(', ', $info['columns'])); + implode(', ', $info['columns'])) . ' ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id)'; } - - //The files table has hash and filename as a unique index. - //Some packs share the same banner for every file, and we only - //ever pull them out by hash. So this saves having loads of entries - $queries[$index] = $query . ' ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id)'; + + $queries[$index] = $query; } // if($queries['TYPE'] == AbstractPopulationHelper::QUERY_TYPE_CREATE)