Welcome Guest, Not a member yet? Register   Sign In
How to get the last Inserted ID after insert data using the query builder ?
#1

Hello !

Does anyone knows how to get the last Inserted ID after insert data using the query builder class?

In CI 3 I just used:
PHP Code:
$this->db->insert_id(); 

What would be the equivalent in CI 4 ?

PHP Code:
    public function insertNewCandidate($candidate) {

        $db      = \Config\Database::connect();
        $builder $db->table('dados_candidates');
        
        $query 
$builder->insert($candidate);

        if( $query ):
            
            
return ?????????????;
            
        
else: 

            return FALSE;
            
        
endif;
        
    


And YES, I do want to use query builder for this... 

I tried to find it in $db, $builder and $query... But it is not there....
Reply


Messages In This Thread
How to get the last Inserted ID after insert data using the query builder ? - by Poetawd - 10-05-2019, 06:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB