/** * Create a contact group with the given name * * @param string The group name * @return mixed False on error, array with record props in success */ function create_group($name) { $result = false; // make sure we have a unique name $name = $this->unique_groupname($name); $this->db->query("INSERT INTO " . $this->db->table_name($this->db_groups) . " (user_id, changed, name)" . " VALUES (" . intval($this->user_id) . ", " . $this->db->now() . ", " . $this->db->quote($name) . ")"); if ($insert_id = $this->db->insert_id($this->db_groups)) { $result = array('id' => $insert_id, 'name' => $name); } return $result; }
/** * 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->quoteIdentifier('type'); $insert_values[] = (int) $data['type']; $insert_cols[] = $this->db->quoteIdentifier('name'); $insert_values[] = $data['name']; $insert_cols[] = $this->db->quoteIdentifier('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'); }
/** * Create a new identity record linked with this user * * @param array $data Hash array with col->value pairs to save * @return int The inserted identity ID or false on error */ function insert_identity($data) { if (!$this->ID) { return false; } unset($data['user_id']); $insert_cols = $insert_values = array(); foreach ((array) $data as $col => $value) { $insert_cols[] = $this->db->quoteIdentifier($col); $insert_values[] = $value; } $insert_cols[] = 'user_id'; $insert_values[] = $this->ID; $sql = "INSERT INTO " . get_table_name('identities') . " (changed, " . join(', ', $insert_cols) . ")" . " VALUES (" . $this->db->now() . ", " . 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('identities'); }