CodeIgniter Select Query

前端 未结 10 974
刺人心
刺人心 2020-12-10 04:37

I have a simple CodeIgniter Active record query to select an ID:

$q = $this -> db
           -> select(\'id\')
           -> where(\'email\', $email         


        
相关标签:
10条回答
  • 2020-12-10 05:28
    public function getSalary()
        {
            $this->db->select('tbl_salary.*,tbl_employee.empFirstName');
            $this->db->from('tbl_salary');
            $this->db->join('tbl_employee','tbl_employee.empID = strong texttbl_salary.salEmpID');
            $this->db->where('tbl_salary.status',0);
            $query = $this->db->get();
            return $query->result();
        }
    
    0 讨论(0)
  • 2020-12-10 05:29
    function news_get_by_id ( $news_id )
    {
    
        $this->db->select('*');
        $this->db->select("DATE_FORMAT( date, '%d.%m.%Y' ) as date_human",  FALSE );
        $this->db->select("DATE_FORMAT( date, '%H:%i') as time_human",      FALSE );
    
    
        $this->db->from('news');
    
        $this->db->where('news_id', $news_id );
    
    
        $query = $this->db->get();
    
        if ( $query->num_rows() > 0 )
        {
            $row = $query->row_array();
            return $row;
        }
    
    }   
    This 
    
    0 讨论(0)
  • 2020-12-10 05:29

    echo $this->db->select('title, content, date')->get_compiled_select();

    0 讨论(0)
  • 2020-12-10 05:33

    This is your code

    $q = $this -> db
           -> select('id')
           -> where('email', $email)
           -> limit(1)
           -> get('users');
    

    Try this

    $id = $q->result()[0]->id;
    

    or this one, it's simpler

    $id = $q->row()->id;
    
    0 讨论(0)
提交回复
热议问题