Syntax for 'where'

5 posts by 3 authors in: Forums > CMS Builder
Last Post: April 13, 2010   (RSS)

By theclicklab - April 12, 2010

Hi there, having probs with the 'where' part of this statement:

$numType = $yacht_typeRecord['url'];
list($yachtsRecords, $yachtsMetaData) = getRecords(array(
'tableName' => 'yachts',
'where' => "type LIKE '$numType'",
'useSeoUrls' => true,
'allowSearch' => false,
'debugSql' =>'true',
));


The record 'type' has multiple values seperated by tabs such as:
" motor catamaran "

any pointers?

Many thanks

Re: [aquaman] Syntax for 'where'

By Jason - April 13, 2010

Hi,

Try changing your first line to this:
$numType="%\t".$yacht_typeRecord['url']."\t%";

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/

Re: [aquaman] Syntax for 'where'

By InHouse - April 13, 2010

Hi aquaman,

There's a fair bit of info on this issue scattered around the forum. I turned up a couple of possible solutions for you with a quick search.

The first thing to try is to put in tab characters in the string used by the LIKE target. For example:

'where' => ' `type` LIKE "%\t$numType\t%" ',

Multi-value lists have tabs separating their values in the database.

Another thing that I do frequently is construct a $whereClause before the list array is built. Then just feed in the simple where clause as needed:

For example:
$urlNum = getNumberFromEndOfUrl();
if ($urlNum >=1):
$whereClause = "type = \"Research Tip\" and num = '{$urlNum}'";
else:
$whereClause = "type = \"Research Tip\" ";
endif;

list($imResearchRecord, $imResearchRecordMetaData) = getRecords(array(
'tableName' => 'tips_inmotion',
'where' => $whereClause,
'limit' => '1',
));


I hope this helps a little. I'm not the real expert here.

J.

Re: [InHouse] Syntax for 'where'

By theclicklab - April 13, 2010

Thanks for the tips, really helps to see working examples - still getting a handle on the correct syntax to use.