Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/Scalia/SphinxSearch/SphinxSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,21 @@ public function get($respect_sort_order = false)
{
$result = \DB::table($config['table'])->whereIn($config['column'], $matchids)->orderByRaw(\DB::raw("FIELD(id, $idString)"))->get();
}

if($result) {
$mode = \Config::get('database.fetch');
$key4result = array();
if($mode == \PDO::FETCH_ASSOC) {
foreach($result as $result_item) {
$key4result[$result_item[$config['column']]] = $result_item;
}
} else {
foreach($result as $result_item) {
$key4result[$result_item->$config['column']] = $result_item;
}
}
$result = $key4result;
unset($key4result);
}
}
}
else
Expand All @@ -189,11 +203,7 @@ public function get($respect_sort_order = false)
$return_val = array();
foreach($matchids as $matchid)
{
$key = self::getResultKeyByID($matchid, $result);
if (false !== $key)
{
$return_val[] = $result[$key];
}
$return_val[$matchid] = $result[$matchid];
}
return $return_val;
}
Expand Down Expand Up @@ -240,6 +250,9 @@ public function getErrorMessage()
return $this->_connection->getLastError();
}

/**
* @deprecated
*/
private function getResultKeyByID($id, $result)
{
if(count($result) > 0)
Expand Down