<commit_before><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Model extends CI_Model {
    
    function __construct() {
        parent::__construct();
        
        
    }
    
    public function add_team() {
        
        $teamdata = array(
            'teamname'  => $this->input->post('teamname'),
            'sport'     => $this->input->post('sport')
                );
        $this->db->insert('teams', $teamdata);
        
        if ($this->db->affected_rows() === 1) {
            
            $insert_id = $this->db->insert_id();
            $this->db->set('user_id', $this->session->userdata('user_id'));
            $this->db->set('team_id', $insert_id);
            $success = $this->db->insert('is_coach_of');
            return $success;
            
        }
    }
    
    public function get_team_by_coach()
    {
        $this->db->select('teamname, id');
        $this->db->from('is_coach_of');
        $this->db->join('teams', 'is_coach_of.team_id = teams.id');
        $this->db->where('is_coach_of.user_id', $this->session->userdata('user_id'));
        $this->db->order_by('teamname', 'asc');
        $query = $this->db->get();<commit_msg>improved add_team function<commit_after><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Model extends CI_Model {
    
    function __construct() {
        parent::__construct();
        
        
    }
    
    public function add_team() {
        
        $teamdata = array(
            'teamname'  => $this->input->post('create_teamname'),
            'sport'     => $this->input->post('create_sport')
                );
        $this->db->insert('teams', $teamdata);
        
        $insertsuccess = $this->db->affected_rows();
        
        if ($this->db->affected_rows() === 1) 
        {
            $insert_id = $this->db->insert_id();
            $this->db->set('user_id', $this->session->userdata('user_id'));
            $this->db->set('team_id', $insert_id);
            $this->db->insert('is_coach_of');
            
            return $insertsuccess;
        }
    }
    
    public function get_team_by_coach()
    {
        $this->db->select('teamname, id');
        $this->db->from('is_coach_of');
        $this->db->join('teams', 'is_coach_of.team_id = teams.id');
        $this->db->where('is_coach_of.user_id', $this->session->userdata('user_id'));
        $this->db->order_by('teamname', 'asc');
        $query = $this->db->get();
{'fraction_non_alphanumeric': 0.18625099920063948, 'fraction_numerical': 0.0007993605115907274, 'mean_word_length': 2.0413122721749697, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6174580', 'n_tokens_mistral': 811, 'n_tokens_neox': 794, 'n_words': 110}