久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PDO 查詢總是返回 1 或 true

PDO query is always returning 1 or true(PDO 查詢總是返回 1 或 true)
本文介紹了PDO 查詢總是返回 1 或 true的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我試圖在刪除某行之前檢查它是否存在.我的表中的行不存在,但它總是返回 1:

I am trying to check if a row exists before I delete it. The row in my table doesn't exist but it always returns 1:

$orders = $this->db->prepare("SELECT * FROM orders WHERE id=? AND user=?"); 
            $check = $orders->execute(array($message,$this->model->checkapi($data,$message)));
            echo $check;
            if($check){
            $deleteorder = $this->db->prepare("DELETE FROM orders WHERE id=? AND user=?"); 
            $deleteorder->execute(array($message,$this->model->checkapi($data,$message)));
                array_push($result, array('success' => true,
                                          'deleted' => $message));
                echo json_encode(array("result" => $result));
                die();
            }else{

$this->model->checkapi($data,$message)返回 fakeusername 和 id/$message 返回 136

$this->model->checkapi($data,$message) returns fakeusername and id/$message returns 136

我檢查了我的數(shù)據(jù)庫,ID 存在,但 ID 和用戶名不存在.

I've checked my database, the ID exists, but not the id and username together.

我正在發(fā)送 ID:136 和用戶名:fakeuser

I'm sending id: 136 and username: fakeuser

在數(shù)據(jù)庫中,該行以 id:136 和用戶名:demo 的形式存在.

in the databse the row exists as id:136 and username: demo.

我不知道為什么當由于不匹配而不應選擇該行時它會返回 1.

I'm not sure why it's returning 1 when the row shouldn't be selected due to it not matching.

推薦答案

你應該在 execute() 之后使用 fetch(),因為 execute() 只在成功時返回 TRUE 或在失敗時返回 FALSE :

You should use fetch() after execute(), because execute() just returns TRUE on success or FALSE on failure :

$orders->execute(...
$result = $orders->fetch(PDO::FETCH_ASSOC);
print_r($result);

這篇關于PDO 查詢總是返回 1 或 true的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 成人福利网站 | 国产1区2区 | 欧美日韩在线不卡 | 国产精品久久777777 | 亚洲一区在线日韩在线深爱 | 欧美理论| 久久久影院 | 亚洲综合久久久 | 777zyz色资源站在线观看 | 国产一区二区影院 | 欧美一级在线 | 在线婷婷 | 日韩欧美一区二区三区 | 一区二区三区视频 | 狠狠爱免费视频 | 91精品久久久久久久久99蜜臂 | 精品欧美一区二区三区久久久 | 秋霞a级毛片在线看 | 日韩精品 | 亚洲国产中文字幕 | 91精品久久久久久久久久入口 | 国产99久久精品一区二区300 | 日韩欧美国产精品综合嫩v 一区中文字幕 | 国产精品99久久久久久久久 | 久草视频在线播放 | 欧美日韩大陆 | 国产精品久久久久无码av | www网站在线观看 | 成人免费看 | 中文字幕亚洲一区二区三区 | 国产精品久久久久久影院8一贰佰 | 一区二区三区精品在线 | 久久高潮 | 天堂国产 | 欧美成年人网站 | 狠狠插天天干 | 国产aⅴ爽av久久久久久久 | a免费视频| 欧美日韩一区二区电影 | 久久精品亚洲国产奇米99 | 啪啪av|