Improved Search Functionality

This commit is contained in:
Joey Kimsey
2025-01-30 18:07:45 -05:00
parent b1e74f9652
commit 795784f02e
3 changed files with 39 additions and 4 deletions

View File

@ -637,10 +637,29 @@ class Database {
return true;
}
public function search( $table, $column, $param ) {
public function searchColumn( $table, $column, $param ) {
return $this->action( 'SELECT *', $table, [$column, 'LIKE', '%' . $param . '%'] );
}
public function search( $table, $columns, $param ) {
if ( empty( $columns ) || ! is_array( $columns ) ) {
Debug::log( 'No columns provided for search' );
return [];
}
$conditions = [];
foreach ( $columns as $column ) {
$conditions[] = $column;
$conditions[] = 'LIKE';
$conditions[] = '%' . $param . '%';
$conditions[] = 'OR';
}
array_pop( $conditions );
return $this->action( 'SELECT *', $table, $conditions );
// return $this->action( 'SELECT ' . implode( ',', $columns ), $table, $conditions ); // need to find a way to casually make this the default....
}
/**
* Selects data from the database.
*