close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MysqlI Search Question - using Comma Sepeated List

Thread began 2/24/2019 8:24 am by Dave Buchholz | Last modified 2/26/2019 9:09 am by Ray Borduin | 448 views | 5 replies |

Dave BuchholzBeta Tester

Mysqli Search Question - using Comma Seperated List

Is there a way to convert this code to work in the MySQLi Search Behaviour so that I can add other dynamic parameters to determine which saved products should be displayed.

<?php 
$products_cookie = json_decode($_COOKIE['compare-products'], true);
$allKeys = array_keys($products_cookie); // see https://stackoverflow.com/a/4095810/175553
$allKeys = str_replace('ITEM-','',$allKeys); // see https://stackoverflow.com/a/4977085/175553
$productIDCollection = implode(',',$allKeys);
?>
<?php
$rsDataSet = new WA_MySQLi_RS("rsDataSet",$connMySQLi,0);
$rsDataSet->setQuery("SELECT p.* FROM tbl_products AS p WHERE p.id IN(?)");
$rsDataSet->bindParam("il", "".$productIDCollection ."", "-1"); //commaDelimitedList
$rsDataSet->execute();
?>



When I add a search to this recordset it removes the existing where clause which I know is expected behaviour.

$allKeys

is an array that could be used but when I try and pass it in I get the following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 78 bytes) in /Users/davidbuchholz/Sites/***/wwwroot/webassist/mysqli/rsobj.php on line 195



The array looks like this:

Array
(
[0] => 1481
[1] => 1480
)



when I do

print '<pre>';
print_r($allKeys);
print '</pre>';



Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure what you mean by "when i add a reach to the recordset"

I think I'll need FTP access to debug and try to reproduce the issue. It should be possible to use search and just set it to keyword search with the implied OR "," since you are passing them in comma separated.

Sign in to reply to this post
Did this help? Tips are appreciated...

Dave BuchholzBeta Tester

Ray, sorry that should read "when i add a search to the recordset", let me try the keyword search idea. If that doesn't work I will post back.

Thanks.

Sign in to reply to this post

Dave BuchholzBeta Tester

Updating my code like so and it works perfectly

<?php 
$products_cookie = json_decode($_COOKIE['compare-products'], true);
$allKeys = array_keys($products_cookie); // see https://stackoverflow.com/a/4095810/175553
$allKeys = str_replace('ITEM-','',$allKeys); // see https://stackoverflow.com/a/4977085/175553
$productIDCollection = implode(', ',$allKeys);
?>
<?php
$searchrsDataSet_1 = new WA_MySQLi_Search("rsDataSet","0=0");
if (true) {
$searchrsDataSet_1->clearSearch();
$searchrsDataSet_1->setSearch(array("type"=>"Key", "comparison"=>"=", "join"=>"AND", "or"=>", ", "or"=>" ", "start_encap"=>"\"", "end_encap"=>"\""), array("id"), "i", "".$productIDCollection ."");
}
?>



Thanks Ray that put me on the right track, it never occurred to me to use a Keyword search for an integer.

Just as a FYI the wizard doesn't give me a choice for integer only Text, Number Boolean or Date and when I choose Number/Boolean it inserts a "d" rather than what I think should be an "i" as the identifier for the type of field it is looking for. Is that correct as I always go back and modify it to an "i" by hand afterwards.

Sign in to reply to this post

Ray BorduinWebAssist

"d" would work just as well... it stands for "double" and works just like integer other than allowing for decimals.

Sign in to reply to this post
Did this help? Tips are appreciated...

Dave BuchholzBeta Tester

Great, thanks Ray much appreciated.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...