• Sorular
  • Etiketler

veritabanına veri eklemek, ve sonra karşılığında bir autogenerated int anahtarı almak

1 Cevap php

Php int executeUpdate(String sql, int autoGeneratedKeys) gibi bir yöntem bulamadı.

Ben veritabanına veri eklemek, ve sonra karşılığında bir autogenerated int tuşuna (ID) almak istiyorum.

Teşekkürler :)

Oh, ve PS: o) = mysqli sınıfından bir yöntem olmalı

1 Cevap

Bkz mysql_insert_id :

mysql_insert_id — Get the ID generated from the previous INSERT operation

(Manuel) Örnek:

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');

mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>

mysqli kullanarak son otomatik oluşturulan anahtarı almak görmek için mysqli->insert_id

0

etiketler

  • php
  • Sorular
  • Etiketler
Copyright © 2014

Powered by EvrenWeb Int. Media.