Skip to content

Commit

Permalink
Include LPs and LLCs in search results
Browse files Browse the repository at this point in the history
This isn't ideal, since the lack of scoring means that we just list results found among corporations and LLCs and LPs — in that order — but at least the results are there. Anything more will need to wait for #70.

Closes #99.
  • Loading branch information
waldoj committed Oct 5, 2019
1 parent 28330a6 commit cd08729
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions includes/class.Business.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function fetch()
}

/**
* Search matching business records, return the first 100
* Search matching business records, return the first 99
*
* @return array
*/
Expand All @@ -96,21 +96,31 @@ function search()
return FALSE;
}

$sql = 'SELECT *
FROM corp
WHERE Name LIKE "%' . $this->query . '%"
LIMIT 100';
$result = $this->db->query($sql);
$this->results = [];

if ($result->numColumns() == 0)
foreach (array('corp', 'llc', 'lp') as $type)
{
return false;

$sql = 'SELECT *
FROM ' . $type . '
WHERE Name LIKE "%' . $this->query . '%"
LIMIT 33';
$result = $this->db->query($sql);

if ($result->numColumns() == 0)
{
continue;
}

while ($business = $result->fetchArray(SQLITE3_ASSOC))
{
$this->results[] = $business;
}
}

$this->results = [];
while ($business = $result->fetchArray(SQLITE3_ASSOC))
if (count($this->results) == 0)
{
$this->results[] = $business;
return FALSE;
}

return $this->results;
Expand Down

0 comments on commit cd08729

Please sign in to comment.