mysql - CFWheels - Order = "random"抛出列错误

标签 mysql sql railo cfwheels cfml

出于某种原因,当我在 findAll() 的顺序子句中指定“随机”时,CFWHeels 抛出错误:

Wheels.ColumnNotFound

Wheels looked for the column mapped to the random property but couldn't find it in the database table. Suggested action

Verify the order argument and/or your property to column mappings done with the property method inside the model's init method to make sure everything is correct.

我以前使用过计算属性,但这不应该是在寻找与“随机”排序有关的任何属性。

<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 语句有关吗?

非常感谢任何帮助。

非常感谢, 迈克尔。

最佳答案

如评论中所述。

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

关于mysql - CFWheels - Order = "random"抛出列错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14505313/

相关文章:

mysql - 在没有 my.conf 文件的 root 访问权限的情况下复制 mysql 数据库?

MySQL/MariaDB 在多核上运行单个查询

coldfusion - 加快 QoQ 速度还是其他方法?

tomcat - Railo 和 Tomcat - 根目录在哪里

php - PHP PDO 的 SQL 内部连接错误

带有连接和子查询的非规范化表中的mysql查询

php - 如果一列有多个关键字,我如何从数据库中获取结果?

sql - 在 Reporting Services 中使用存储过程

coldfusion - 如何在 cfscript 标记内执行 cfdump?

java - 继续下一个 mySQL 行 JAVA