Remove record num from _link
23 posts by 4 authors in: Forums > CMS Builder
Last Post: December 12, 2012 (RSS)
By Jason - December 12, 2012
Hi Kevin,
There isn't a trim taking place, since the only difference between the 2 tests is the presence of a trailing space inside the record, which wouldn't appear in the query. One thing you can try is to trim the address field in the database from inside your where clause like this:
This should remove any leading or trailing spaces before the LIKE comparison is done.
Hope this helps
There isn't a trim taking place, since the only difference between the 2 tests is the presence of a trailing space inside the record, which wouldn't appear in the query. One thing you can try is to trim the address field in the database from inside your where clause like this:
// load records
list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'where' => " TRIM(address) LIKE '".mysql_escape($title_like)."'",
'limit' => '1',
));
This should remove any leading or trailing spaces before the LIKE comparison is done.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
By weblm - December 12, 2012
Jason thanks! That looks like it's working.
Any ideas what was happening? Still not sure I completely understand all the preg_replace code.
Thanks for the help!
-Kevin
Any ideas what was happening? Still not sure I completely understand all the preg_replace code.
Thanks for the help!
-Kevin
LM
By Jason - December 12, 2012
Hi Kevin,
What was happening is that the value stored in the database was "Acorn Lodge " but we were searching for "Acorn_Lodge", which doesn't take allow for the trailing space at the end. Using TRIM(address) removes the trailing space, so we are then comparing "Acorn Lodge" to "Acorn_Lodge". The "_" is a MySQL is a wildcard that can represent any character, in this case a space. So these two strings are now the same.
Hope this helps. Please let me know if you have any other questions.
Thanks,
What was happening is that the value stored in the database was "Acorn Lodge " but we were searching for "Acorn_Lodge", which doesn't take allow for the trailing space at the end. Using TRIM(address) removes the trailing space, so we are then comparing "Acorn Lodge" to "Acorn_Lodge". The "_" is a MySQL is a wildcard that can represent any character, in this case a space. So these two strings are now the same.
Hope this helps. Please let me know if you have any other questions.
Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/