2015-07-12 77 views
0

我是數據庫新手,我很討厭它。如何在WordPress中從數據庫檢索值?

受影響的表的結構如下:

1)表:wp_tdpp_commentmeta

-------------------------------------------- 
meta_id comment_id meta_key meta_value 
-------------------------------------------- 
1   18   secretid private 
-------------------------------------------- 
2   19   secretid public 
-------------------------------------------- 
... 

2)表:wp_tdpp_comments

------------------------------------------------------ 
comment_ID comment_post_ID ..... comment_content 
------------------------------------------------------ 
18   14    .... Comment Content for this comment_id 
19   14    ... ditto 

... 
------------------------------------------------------ 

的 「wp_tdpp_commentmeta」是由用戶輸入的自定義評論元字段當寫評論時。

我想檢查當前comment_ID的'meta_value'的值是「private」還是「public」。

+0

請注意,meta_id顯然沒有用處,因爲似乎有一個非常好的自然pk(comment_id,meta_key)。 – Strawberry

+0

查看wordpress教程並使用正確的wp功能,你有什麼是黑客等待發生。從https://codex.wordpress.org/Template_Tags/get_posts和https://codex.wordpress.org/Function_Reference /get_post_meta。如果你沒有通過主題添加自定義表格,一般的規則是,如果你使用的表名是你做錯了 – Mihai

+0

@Mihai。非常感謝參考頁面。我會仔細閱讀。 – Peter

回答