CFWheels - Order =“random”抛出一个列错误

时间:2013-01-24 15:49:57

标签: mysql sql railo cfwheels cfml

出于某种原因,当我在findAll()的order子句中指定“random”时,CFWHeels会抛出错误:

  

Wheels.ColumnNotFound

     

车轮查找映射到随机属性的列,但是   无法在数据库表中找到它。建议采取的行动

     

验证订单参数和/或属性是否已完成列映射   使用模型的 init 方法中的属性方法来确保   一切都是正确的。

之前我使用过计算过的属性,但是这不应该是关于“随机”排序的任何一个。

<cffunction name="random">

    <cfparam name="params.page" default="1" />
    <cfparam name="params.pageQuantity" default="5" />

    <cfset posts = model("post").findAll(

        select = "

            posts.postID,
            postTitle,
            postPoints,
            postAuthority,
            postCreated,

            postCommentCount,
            postUpVoteCount,
            postDownVoteCount,

            users.userID,
            userName,

            categories.categoryID,
            categoryTitle,
            categoryToken",

        include     = "user,category", 
        order       = "random",
        page        = params.page,
        perPage     = params.pageQuantity

    ) />

</cffunction>

这可能与使用select声明有关吗?

感谢任何帮助。

非常感谢, 迈克尔。

1 个答案:

答案 0 :(得分:3)

正如在作品中所确定的那样。

如果order by rand()在mySQL中有效,那么我首先尝试的是在wheel函数中order = 'rand()'