Database : Update (CRUD)

  • do_update
    This query method is the top level sql setter method for updating data in the database fields. It defines sql select queries that can be executed later.
    Method 1 : Update (set query)
      $db->do_update('users')
    
         ->set("gender=?")
    
         ->where('id=?');
    
         ->setData(['MALE', $userid]) 
                        

    Method 2 : Update (set query)
      $db->query('update users set firstname = ?, lastname = ? where username = ?', ['Felix','Russel','Brown']);
                        
    The method above is used to set simple sql queries. Method where() should only be chained once on the do_update() operator in the predefined order.
  • insert
    This method executes predefined update queries.
    Example 4 : Data Insertion
      $db->query('update users set firstname = ? where username = ?',['Felix','Rolland'])->insert();
                        
    In the example above, we executed the insertion query by calling the insert() method