簡體   English   中英

從表中選擇要更新其他表值的表Codeigniter問題

[英]Selecting from table where value update other table value Codeigniter problem

我有我試圖從表中選擇“命令”列“自定義”,如果該電子郵件地址誰是當前登錄就需要設置用戶的電子郵件地址相匹配的值的一些問題,我的笨網站'donater''users' table to 1 但是我收到一條錯誤消息。 我幾乎沒有編碼經驗,這是我想到的:

public function hasDonated($email){
$this->db->from('orders');
    $this->db->where('custom', $email);
    $this->db->update('users', array('donater' => '1'));
    return;
}

這是我得到的錯誤,它試圖在users表中選擇'custom' ,但需要從“訂單”表中進行選擇,我做錯了什么?

Unknown column 'custom' in 'where clause'

UPDATE `users` SET `donater` = '1' WHERE `custom` = 'testing@test.com'

您可以按照以下方式進行操作:

public function hasDonated($email){
$resp = $this->db->select('custom')->from('orders')->where('custom',$email)->get();
    if( $resp->num_rows() > 0 ) {   
    $this->db->set('donater', 1);
    $this->db->where('email', $email);
    $this->db->update('users');
  }
  return;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM