2013-02-27 25 views
0

我有一個名爲「集合」從紅豆產生的,與這些列的表:紅豆發現任何數據類型

id  - INT(11) 
user_id - TINYINT(3) 
code - VARCHAR(255) 
sample - INT(11) 

但是當我「退出」這樣的代碼:

$aggregates = json_encode(Orm::exportAll(Orm::find('aggregates'))); 
exit($aggregates); 

從PHP,我得到這個JSON輸出:

[ 
{"id":"1", "user_id":"1", "code":"baffdadsad", "sampleWeight":"100"}, 
{"id":"2", "user_id":"1", "code":"prova",  "sampleWeight":"900"}, 
{"id":"3", "user_id":"1", "code":"asdsa",  "sampleWeight":"120"}, 
{"id":"4", "user_id":"2", "code":"grana",  "sampleWeight":"89"}, 
{"id":"14", "user_id":"1", "code":"get",  "sampleWeight":"1001"}, 
{"id":"15", "user_id":"1", "code":"saghf",  "sampleWeight":"232"} 
] 

IDsampleWeight領域應該是,爲什麼Redbeans不承認?我能做什麼?

上紅豆文檔http://redbeanphp.com/import_and_export 我發現這個文本部分:

由於3.3版:僅導出一組特定的bean類型如下:R :: exportAll($豆類,真實,$過濾器);這裏$過濾器中包含的類型的列表導出。

可能exportAll我的問題嗎?

回答

1

我的問題可以通過使用JSON_NUMERIC_CHECK predefined constant這樣解決:

$json_aggregates = json_encode($array, JSON_NUMERIC_CHECK); 

,將輸出用數字代替串號碼正確的JSON,我不知道,如果是最好的解決方案通過方法...

相關問題