Public feed
#725201
/** * Gets specified or all data from the user database. * * @param array, string $fields * @return instance */function get($fields = NULL){ // Select all fields if none specified if (!$fields) $fields = '*'; // Select an array of fields from a $fields elseif (is_array($fields)) $fields = implode(', ', $fields); // Select only one field else $this->field = $fields; // Create select statement $this->sql = "SELECT $fields FROM $this->user_table AS t1 "; return $this;}/** * Gets specified or all data from the user database joined with the group database. * * @param array, string $fields * @return instance */function get_group($fields = NULL){ // Select all fields (from the left table, t1) if none specified if (!$fields) $fields = '*'; // Select an array of fields from a $fields elseif (is_array($fields)) $fields = implode(', ', $fields); // Select only one field else $this->field = $fields; // Create select statement $this->sql = " SELECT t2.$fields FROM users AS t1 LEFT JOIN user_groups AS t2 ON (t1.user_group_id = t2.user_group_id) "; return $this;}/** * Narrows the scope of a get*() call to only the specified email * * @param unknown_type $email * @return instance */function where_email($email){ // Create where statement $this->sql .= "WHERE t1.email = '$email' "; return $this;}/** * Executes a specified query and returns either a result array, row array, or single column. * * @param string $result_type * @return array, bool, string */function execute($result_type = 'result_array'){ // Execute the query $this->query = $this->db->query($this->sql); // Returns false if no rows resulted from the query if ($this->query->num_rows() == 0) return FALSE; // Returns a string if this is only one column else { switch ($result_type) { case 'result_array': return $this->query->result_array(); break; case 'row_array': return $this->query->row_array(); break; case 'string': $array = $this->query->row_array(); return $array[$this->field]; } } // Unset the transfered field; unset($this->field);}