Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Commit

Permalink
Fixed suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Kurczewski committed Aug 22, 2013
1 parent 6cbf12f commit 02d0052
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Models/Model_MixedUserMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,18 @@ public static function getFranchises(array $ownEntries, $loadEverything = false)

if ($loadEverything)
{
$tblName = self::createTemporaryTable($entries);
$tblName = 'hurr';
$query = 'CREATE TEMPORARY TABLE ' . $tblName . ' (franchise VARCHAR(10))';
R::exec($query);
foreach (array_chunk(array_keys($ownClusters), Config::$maxDbBindings) as $chunk)
{
$query = 'INSERT INTO ' . $tblName . ' VALUES ' . join(',', array_fill(0, count($chunk), '(?)'));
R::exec($query, $chunk);
}
$query = 'SELECT * FROM media INNER JOIN ' . $tblName . ' ON media.franchise = ' . $tblName . '.franchise';
$rows = R::getAll($query);
self::dropTemporaryTable($tblName);
$query = 'DROP TABLE ' . $tblName;
R::exec($query);

$allEntries = array_map(function($entry) { return new Model_MixedUserMedia($entry); }, $rows);
$allClusters = self::clusterize($allEntries);
Expand Down

0 comments on commit 02d0052

Please sign in to comment.