CodeIgniter Forums

Full Version: how to use IS NULL?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have problem with my query, its not update my table

*I want select NULL col with limit then update the DB.

this is my code model:

PHP Code:
function SetUserTakenStock($data$id$totalTaken)
 
 {
 
   $this->db->trans_start();
 
   $this->db->select('*');
 
   $this->db->from('user_id');
 
   $this->db->where('status IS NULL');
 
   $this->db->set('status'$data);
 
   $this->db->where('user_id'$id);
 
   $this->db->limit($totalTaken);
 
   $this->db->update('gen_set');

 
   $this->db->trans_complete();
 
   if ($this->db->trans_status() === TRUE)
 
   {
 
     return true;
 
   }
 
   else
    
{
 
     return false;
 
   }
 
 
(04-08-2017, 09:37 PM)falcon812311 Wrote: [ -> ]Hi,

I have problem with my query, its not update my table

*I want select NULL col with limit then update the DB.

this is my code model:

PHP Code:
function SetUserTakenStock($data$id$totalTaken)
 
 {
 
   $this->db->trans_start();
 
   $this->db->select('*');
 
   $this->db->from('user_id');
 
   $this->db->where('status IS NULL');
 
   $this->db->set('status'$data);
 
   $this->db->where('user_id'$id);
 
   $this->db->limit($totalTaken);
 
   $this->db->update('gen_set');

 
   $this->db->trans_complete();
 
   if ($this->db->trans_status() === TRUE)
 
   {
 
     return true;
 
   }
 
   else
    
{
 
     return false;
 
   }
 
 

I think that should be :
Code:
$this->db->where('status', null);
Not related to the answer but this code

PHP Code:
if ($this->db->trans_status() === TRUE)
 
   {
 
     return true;
 
   }
 
   else
    
{
 
     return false;
 
   

Can be expressed with a lot less typing Rolleyes

PHP Code:
return $this->db->trans_status();