Chill_user Posted May 7, 2020 Share Posted May 7, 2020 Hello to all, I have next query which gives "false" result, but data exists in the table. $search_param = "test"; $query = 'SELECT * FROM `'._DB_PREFIX_.'test` WHERE `link_rewrite` = '.$search_param; $result = Db::getInstance()->ExecuteS($query); If I make "Select *" from table = all is working. Whats the problem with showed before code? Thanks a lot! Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2020 Share Posted May 7, 2020 (edited) $search_param = "'%".test."%'"; $query = 'SELECT * FROM `'._DB_PREFIX_.'test` WHERE `link_rewrite` LIKE '.$search_param; $result = Db::getInstance()->ExecuteS($query); or $search_param = "'".test."'"; $query = 'SELECT * FROM `'._DB_PREFIX_.'test` WHERE `link_rewrite` = '.$search_param; $result = Db::getInstance()->ExecuteS($query); or $search_param = 'test'; $query = "SELECT COUNT(`link_rewrite`) AS count FROM `"._DB_PREFIX_."test` WHERE `link_rewrite` = ".$search_param; $result = Db::getInstance()->getValue($query); if ($result['count'] == '0') { echo 'URL rewrite: '.$search_param.' not exists'; } else { echo 'URL rewrite: '.$search_param.' exists in databse. Count: '.$result['count']; } Edited May 7, 2020 by Guest (see edit history) Link to comment Share on other sites More sharing options...
Chill_user Posted May 7, 2020 Author Share Posted May 7, 2020 Working perfectly (2d code), thanks! Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2020 Share Posted May 7, 2020 1 minute ago, Amantha Bill said: Working perfectly (2d code), thanks! 3d code now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now