where clause is ignored

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 4, 2010   (RSS)

Re: [mdegive] where clause is ignored

By Jason - November 4, 2010

Hi,

You're "where" clause isn't being ignored, but it is being appended. There is probably something in your query string like num=2 or 2 being the last number in your query string and that's where this number is coming from.

You can get around this by setting allowSearch to false like this:

list($orderRecords, $orderMetaData) = getRecords(array(
'tableName' => 'report_order',
'where' => 'num=1',
'allowSearch' => false,
));
$orderRecord = $orderRecords[0]; // get first record


Also, if this is a single record section, there isn't any need for a where clause at all, there will only ever be one record, so you could also change it to this:

list($orderRecords, $orderMetaData) = getRecords(array(
'tableName' => 'report_order',
'allowSearch' => false,
));
$orderRecord = $orderRecords[0]; // get first record


This will just get the first record for that section. Since there is only 1, it will always be the first one.

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: [Jason] where clause is ignored

By mdegive - November 4, 2010

thanks for your quick reply, that did it, but I thought that by removing the whereRecordNumberInUrl(1), it would then ignore the query string

Re: [mdegive] where clause is ignored

By Jason - November 4, 2010

Hi,

It depends on what is in the query string. If a variable name in the query string matches a field in a section you're searching(like num), it will automatically add that to the where clause. Turning off allowSearch will prevent it from doing this.

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/