mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Merge pull request #28 from BreizhHardware/cfouche
Add Full text search
This commit is contained in:
@@ -4,8 +4,9 @@ require_once '../API/src/response.php';
|
||||
// searchDoctor search doctor by name or specialty and return the result in JSON format
|
||||
function searchDoctor($pdo, $type): void
|
||||
{
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_specialty = :type");
|
||||
$query->bindParam(':type', $type);
|
||||
$queryvar = "%".$type."%";
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_specialty ILIKE :type");
|
||||
$query->bindParam(':type', $queryvar);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
// Check if the query returned any result
|
||||
@@ -14,8 +15,8 @@ function searchDoctor($pdo, $type): void
|
||||
$count++;
|
||||
}
|
||||
if($count == 0){
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_name = :type");
|
||||
$query->bindParam(':type', $type);
|
||||
$query = $pdo->prepare("SELECT m_name, m_surname, m_postal, m_specialty, m_phone, m_id FROM medecin WHERE m_name ILIKE :type");
|
||||
$query->bindParam(':type', $queryvar);
|
||||
$query->execute();
|
||||
$result = $query->fetchAll();
|
||||
$count = 0;
|
||||
|
||||
Reference in New Issue
Block a user