/**
  * Update a specific contact record
  *
  * @param mixed Record identifier
  * @param array Assoziative array with save data
  *
  * @return boolean True on success, False on error
  */
 function update($id, $save_cols)
 {
     $updated = false;
     $write_sql = array();
     $record = $this->get_record($id, true);
     $save_cols = $this->convert_save_data($save_cols, $record);
     foreach ($save_cols as $col => $value) {
         $write_sql[] = sprintf("%s=%s", $this->db->quote_identifier($col), $this->db->quote($value));
     }
     if (!empty($write_sql)) {
         $this->db->query("UPDATE " . $this->db->table_name($this->db_name, true) . " SET `changed` = " . $this->db->now() . ", " . join(', ', $write_sql) . " WHERE `contact_id` = ?" . " AND `user_id` = ?" . " AND `del` <> 1", $id, $this->user_id);
         $updated = $this->db->affected_rows();
         $this->result = null;
         // clear current result (from get_record())
     }
     return $updated ? true : false;
 }
 /**
  * Create a new saved search record linked with this user
  *
  * @param array $data Hash array with col->value pairs to save
  *
  * @return int  The inserted search ID or false on error
  */
 function insert_search($data)
 {
     if (!$this->ID) {
         return false;
     }
     $insert_cols[] = 'user_id';
     $insert_values[] = (int) $this->ID;
     $insert_cols[] = $this->db->quote_identifier('type');
     $insert_values[] = (int) $data['type'];
     $insert_cols[] = $this->db->quote_identifier('name');
     $insert_values[] = $data['name'];
     $insert_cols[] = $this->db->quote_identifier('data');
     $insert_values[] = serialize($data['data']);
     $sql = "INSERT INTO " . $this->db->table_name('searches') . " (" . join(', ', $insert_cols) . ")" . " VALUES (" . join(', ', array_pad(array(), sizeof($insert_values), '?')) . ")";
     call_user_func_array(array($this->db, 'query'), array_merge(array($sql), $insert_values));
     return $this->db->insert_id('searches');
 }