2013-01-24 38 views
0

出於某種原因,當我指定的findAll()的我的訂單條款「隨機」,CFWHeels拋出一個錯誤: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語句有關?

希望得到任何幫助。

非常感謝, Michael。

+0

這會產生什麼樣的sql?如果你直接對你的數據庫運行sql,會發生什麼? –

+0

@DanBracuk我無法查看生成的SQL,因爲這是一個CFWheels錯誤頁面,而不是一個Railo錯誤 - 有什麼辦法可以做到這一點? –

+0

它可能是一個CFWheels錯誤頁面,但確實看起來像一個數據庫錯誤。當random既不是您的select子句的字段名也不是別名時,您的數據庫是否支持「隨機排序」? –

回答

3

正如建議中所述。

如果order by rand()在mySQL中起作用,我會嘗試的第一件事情就是在wheels函數中使用order = 'rand()'

+0

謝謝,這解決了我的問題! –