• Is it possible to do multiple queries in a single call to any of the $wpdb class methods?

    Here’s what I want to do… I have a database table that contains records describing banner ads. Depending on the advertising program, there might be just one or two ads in each size, or there might be a bunch. However, I want to give the ads from the different programs equal weight.

    That is, if there are 2 ads from Amazon, 96 from “ad-setup1” and 56 from “ad-setup2”, I don’t want to see the ads from “ad-setup1” 48 times more often than the ads from Amazon. In order to accomplish this, I first need to randomly select the ad program, then use that info to help me select an individual ad.

    Here’s what I would *like* to do:

    SET @src=(SELECT DISTINCT source from ads order by rand() limit 0,1);
    SELECT * FROM ads WHERE source=@src ORDER BY id;

    The problem is, it doesn’t work. Any attempt to issue multiple queries fails.

    Does anybody have any data on this? My guess is that the reason is that the $wpdb class is calling the old mysql* functions, which don’t support this concept, instead of the newer mysqli* functions which do.

    Any ideas?

Viewing 1 replies (of 1 total)
  • Thread Starter mikefulton

    (@mikefulton)

    By the way, yes, I know how to accomplish the result by making separate calls. I was just hoping for a more efficient solution.

Viewing 1 replies (of 1 total)

The topic ‘Multi-part queries?’ is closed to new replies.