Improved Search Functionality
This commit is contained in:
@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user