我創(chuàng)建了一個函數(shù),我只需要獲取單個數(shù)據(jù)由于某種原因它不起作用,我不知道是什么問題這是我的代碼$functions->fetch_single('user_tbl', $objectID, $id, 'hidden_post');function fetch_single($table_name = '' ,$where = '', $where2 = '', $fetch = '', $debug=false){ $query = "SELECT * FROM $table_name WHERE $where = $where2"; if($debug){ exit($query); } $statement = $this->connection->prepare($query); if($statement->execute()){ $fetch_single_data = $statement->fetchAll(PDO::FETCH_ASSOC); return $fetch_single_data[0]['$fetch']; } return false;} function execute_query($query){ $statement = $this->connection->prepare($query); if( $statement->execute() ){ return $statement; } return false;}它甚至沒有進(jìn)入 if 語句執(zhí)行,我不知道是什么問題。請幫忙謝謝
1 回答

慕運維8079593
TA貢獻(xiàn)1876條經(jīng)驗 獲得超5個贊
已經(jīng)解決了問題謝謝你們幫助我我只需要在我的 SQL 中的字符串值周圍添加引號
$query = "SELECT * FROM $table_name WHERE $where = '$where2'";
- 1 回答
- 0 關(guān)注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消