Skip to content

Instantly share code, notes, and snippets.

@pyldin601
Created March 21, 2016 09:27
Show Gist options
  • Save pyldin601/085fb348d25ed36107b5 to your computer and use it in GitHub Desktop.
Save pyldin601/085fb348d25ed36107b5 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: Roman
* Date: 24.02.2016
* Time: 9:45
*/
namespace App\Dao;
class VacancyDao extends AbstractWithAliasDao
{
protected $table = 'vacancy';
public function getListRelated($vacancy)
{
$st = $this->connection->getPdo()->prepare("
SELECT *, MATCH(`search`) AGAINST(:kw) AS `match`
FROM `vacancy` WHERE
MATCH(`search`) AGAINST(:kw) AND
`id` != :id AND
`salary` BETWEEN :salary - :tolerance AND :salary + :tolerance
ORDER BY `match` DESC
LIMIT :limit");
$st->bindValue("kw", $vacancy["search"], \PDO::PARAM_STR);
$st->bindValue("id", $vacancy["id"], \PDO::PARAM_INT);
$st->bindValue("limit", config("legacy.related_vacancies_limit"), \PDO::PARAM_INT);
$st->bindValue("salary", (int) $vacancy["salary"], \PDO::PARAM_INT);
$st->bindValue("tolerance", 6000, \PDO::PARAM_INT);
$st->execute();
return $st->fetchAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment