I am having some problems with my CodeIgniter website I am trying to select a value from the table 'orders' column 'custom' if this email address matches the user's email address who is currently logged it will need to set the 'donater'
in the 'users' table to 1
. But I get an error message. I have very little coding experience this is what I came up with:
public function hasDonated($email){
$this->db->from('orders');
$this->db->where('custom', $email);
$this->db->update('users', array('donater' => '1'));
return;
}
This is the error I get it tries to select 'custom'
in the users
table but it needs to be selected from the 'orders' table what aI i doing wrong?
Unknown column 'custom' in 'where clause'
UPDATE `users` SET `donater` = '1' WHERE `custom` = 'testing@test.com'
You can do it as:
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.