用于Wordpress数据查询的高效随机化器

时间:2014-08-06 18:51:55

标签: php mysql wordpress random

我发现以下mysql随机数发生器但似乎无法掌握应用于我的代码的语法。随机发生器是:

SELECT  *
FROM    (
        SELECT  @cnt := COUNT(*) + 1,
                @lim := 10
        FROM    t_random
        ) vars
STRAIGHT_JOIN
        (
        SELECT  r.*,
                @lim := @lim - 1
        FROM    t_random r
        WHERE   (@cnt := @cnt - 1)
                AND RAND(20090301) < @lim / @cnt
        )

我需要将它应用于wordpress mysql查询。

$query = "
        SELECT ID from $wpdb->posts p
        JOIN $wpdb->postmeta meta1 ON meta1.post_id = p.ID
        WHERE p.post_status = $post_status
        AND p.post_type = $post_type
        AND meta1.meta_key = 'gallery'
        AND meta1.meta_value = '$gallery'";

0 个答案:

没有答案