遨遊飛翔 | 學習筆記 For php、jQuery、MySql、Centos、Suse、Server

五月/09

11

Mysql to json

最近剛好在 phpclasses 裡看到有人提供 mysql_to_json,這似乎是挺有趣的一個東西,在好奇之下把檔案抓來試用看看,使用相當簡單而且檔案又很小,或許之後會有用到。在php裡直接寫好條件查詢sql後再丟給這隻去回傳資料庫查到的資料,嗯…或許也是一個方式。

檔案:mysql_to_json

使用:

載入mysql_to_json class
include(‘mysql_to_json.class.php’);

方式1:

// 建立一個新的mysql_to_json介面
$mtj = new mysql_to_json($query);

//輸出
echo $mtj->get_json();

方式2:

//建立一個新的空的mysql_to_json 介面
$mtj = new mysql_to_json();

//輸出
echo $mtj->set_query($query)->set_cbfunc(‘loels’)->get_json();

結論:

試用後感覺還蠻方便的,之後需要直接撈資料庫資料再回傳給javacript時,或許可以考慮直接使用它來回傳資料

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Hemidemi
  • Live
  • email
  • TwitThis
  • Twitter

相關文章

RSS Feed

仍無迴響。

Leave a comment!

<<

>>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Find it!

Theme Design by devolux.org