From 2802526a6bd4a8999d76fe6813992d4fe68855c1 Mon Sep 17 00:00:00 2001 From: ozh Date: Tue, 28 Oct 2014 20:17:35 +0100 Subject: [PATCH] CONCAT_WS instead of CONCAT --- admin/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/index.php b/admin/index.php index 773db82..913c8c5 100644 --- a/admin/index.php +++ b/admin/index.php @@ -56,9 +56,10 @@ $search_text = $search; $search = str_replace( '*', '%', '*' . yourls_escape( $search ) . '*' ); if( $search_in == 'all' ) { - $where .= " AND CONCAT(`keyword`,`url`,`title`,`ip`) LIKE ('$search')"; + $where .= " AND CONCAT_WS('',`keyword`,`url`,`title`,`ip`) LIKE ('$search')"; // Search across all fields. The resulting SQL will be something like: - // SELECT * FROM `yourls_url` WHERE CONCAT(`keyword`,`url`,`title`,`ip`) LIKE ("%ozh%") + // SELECT * FROM `yourls_url` WHERE CONCAT_WS('',`keyword`,`url`,`title`,`ip`) LIKE ("%ozh%") + // CONCAT_WS because CONCAT('foo', 'bar’, NULL) = NULL. NULL wins. Not sure if values can be NULL now or in the future, so better safe. // TODO: pay attention to this bit when the DB schema changes } else { $where .= " AND `$search_in` LIKE ('$search')"; -- 2.45.0