Nasıl sadece PHP / MySQL ile DB sokulduktan satır erişmek için?
I var:
$sql = 'INSERT INTO `jos_db`.`jos_sections` (`id`, `name`) VALUES (NULL, \'foo\')';
mysql_query($sql, $dbi);
bar();
Nasıl I) (bar yeni satır girebilirim?
Eğer 'id' sütunu bir otomatik artım ise, kullanabilirsiniz mysql_insert_id:
Retrieves the ID generated for an
AUTO_INCREMENT
column by the previousINSERT
query.
The example given in the manual looks like this :
$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());