close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Can't figure out the operator like BETWEEN, coma seperated value etc in advance query builder

Thread began 4/20/2020 8:48 am by Rokon | Last modified 4/20/2020 5:44 pm by Ray Borduin | 755 views | 11 replies |

Rokon

Can't figure out the operator like BETWEEN, coma seperated value etc in advance query builder

Hello

I am having some trouble with the advance sqli query builder. I need to filter my records by passing url variable with coma separated value like
bookID=1,20,25 etc and also another with the BETWEEN like bookID=2-5 but could not figure it out on the builder.

Please help.

Sign in to reply to this post

Ray BorduinWebAssist

That probably can't be done with the builder. Some complex queries still have to be written by hand.

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

Rokon

Originally Said By: Ray Borduin
  That probably can't be done with the builder. Some complex queries still have to be written by hand.  


Dear Ray

Please give me an example of a query as like below;

<?php
$mainHadith = new WA_MySQLi_RS("mainHadith",$hadithbd,10);
$mainHadith->setQuery("SELECT hadithmain.HadithID, hadithmain.CheckStatus, hadithmain.BookID, hadithmain.chapterID, hadithmain.SectionID, hadithmain.HadithNo, hadithmain.ArabicHadith, hadithmain.ArabicHadithNew, hadithmain.BanglaHadith, hadithmain.EnglishHadith, hadithmain.HadithNote, hadithmain.HadithActive, hadithmain.HadithStatus, hadithbook.totalHadith, hadithbook.BookNameBD, hadithchapter.ChapterBG, hadithchapter.ChapterAR, hadithchapter.ChapterEN, hadithexplanation.explanation, hadithsource.SourceNameBD, hadithsource.SourceNameEN, hadithstatus.StatusBG, rabihadith.rabiBangla, rabihadith.rabiEnglish, hadithsection.SectionBD, hadithsection.SectionEN FROM hadithmain LEFT OUTER JOIN hadithbook ON hadithmain.BookID = hadithbook.BookID LEFT OUTER JOIN hadithchapter ON hadithmain.chapterID = hadithchapter.chapID LEFT OUTER JOIN hadithexplanation ON hadithmain.HadithID = hadithexplanation.hadithID LEFT OUTER JOIN hadithsource ON hadithmain.SourceID = hadithsource.SourceID LEFT OUTER JOIN hadithstatus ON hadithmain.HadithStatus = hadithstatus.StatusID LEFT OUTER JOIN rabihadith ON hadithmain.RabiID = rabihadith.rabiID LEFT OUTER JOIN hadithsection ON hadithmain.SectionID = hadithsection.SectionID WHERE hadithmain.HadithActive = 1 AND hadithmain.HadithNo = ? HAVING hadithmain.BookID = ? ORDER BY hadithmain.HadithNo ASC");
$mainHadith->bindParam("i", "".(isset($_GET['hadith'])?$_GET['hadith']:"") ."", "-1"); //WAQB_Param1
$mainHadith->bindParam("i", "".(isset($_GET['book'])?$_GET['book']:"") ."", "-1"); //WAQB_Param2
$mainHadith->execute();
?>


Here I need to filter the hadithmain.HadithNo by passing a GET value called $mainHadith->bindParam("i", "".(isset($_GET['hadith'])?$_GET['hadith']:"") ."", "-1"); //WAQB_Param1


I need to send search query like index.php?hadith=1,5,10 etc

And in another search I need to get result of in between value from the same filed of hadithmain.HadithNo

Thanks in advance

Sign in to reply to this post

Ray BorduinWebAssist

Try:

HAVING hadithmain.BookID = ? ORDER BY hadithmain.HadithNo ASC");
$mainHadith->bindParam("il", "".(isset($_GET['hadith'])?$_GET['hadith']:"") ."", "-1"); //WAQB_Param1

adding the "l" to the parameter tell it that you are passing an "integer list" and not a single integer.

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

Rokon

Originally Said By: Ray Borduin
  Try:

HAVING hadithmain.BookID = ? ORDER BY hadithmain.HadithNo ASC");
$mainHadith->bindParam("il", "".(isset($_GET['hadith'])?$_GET['hadith']:"") ."", "-1"); //WAQB_Param1

adding the "l" to the parameter tell it that you are passing an "integer list" and not a single integer.  




After changing and passing value to url like index.php?hadith=1,2 it shows
There is an error in your SQL syntax.

Sign in to reply to this post

Ray BorduinWebAssist

Sorry I forgot you have to change the comparison too... Instead of:

hadithmain.HadithNo = ?

it should be:

hadithmain.HadithNo IN (?)

If you supply a url and copy of the page it would help me ensure I'm giving the correct advice.

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

Rokon

Originally Said By: Ray Borduin
  Sorry I forgot you have to change the comparison too... Instead of:

hadithmain.HadithNo = ?

it should be:

hadithmain.HadithNo IN (?)

If you supply a url and copy of the page it would help me ensure I'm giving the correct advice.  


Yes now it works! Thanks a lot.
Little more guide is needed for the BETWEEN result is needed please.

Sign in to reply to this post

Rokon

Originally Said By: Ray Borduin
  Try:

HAVING hadithmain.BookID = ? ORDER BY hadithmain.HadithNo ASC");
$mainHadith->bindParam("il", "".(isset($_GET['hadith'])?$_GET['hadith']:"") ."", "-1"); //WAQB_Param1

adding the "l" to the parameter tell it that you are passing an "integer list" and not a single integer.  


You can have a look at http://new.hadithbd.com/hadith/filter/?hadith=12&book=22

login detail in private

Sign in to reply to this post

Ray BorduinWebAssist

It looks like it is working now.

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

Rokon

Originally Said By: Ray Borduin
  It looks like it is working now.  



Yes is working with coma separated value like http://new.hadithbd.com/hadith/filter/?hadith=12,14&book=22 and many many thanks for your support
& I have little more to solve here which is the query for the BETWEEN value like

http://new.hadithbd.com/hadith/filter/?hadith=12-14&book=22

so that it will bring all result between 12 to 14

Pls help

Sign in to reply to this post
loading

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...