Primary key return of an INSERT

Asked

Viewed 118 times

3

I have the tabela_x, where the first field (campo1) is primary key and autoincrement.

I make a simple INSERT:

$ins = " INSERT INTO tabela_x (`campo2`,`campo3`,`campo4`) VALUES ($c2, $c3, $c4) ";
$con -> query($ins)

I would like to get the return of this Internet, with the value of the campo1.

I’ll always have to make one select shortly after the insert just to take that amount or have some way I perform the query of the Insert, taking as return the value ?

1 answer

4


  • That’s right professor ! In my case it is $con -> insert_id (http://php.net/manual/en/mysqli.insert-id.php). ;]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.