Get Next Auto Increment
Dit is een functie waarmee je de volgende auto increment krijgt uit de opgegeven tabel. Als iemand nog feedback heeft hoor ik dat graag. Groeten, R. Vandenbussche Author: Ruben Vandenbussche Website: http://www.RVandenbussche.nl Contact: info (at) RVandenbussche (dot) nl Date: 11 Nov 2008 ******************************************* Script: Get Auto Increment v1.0 It does: 1. Get the next auto increment from the table. It doesn't: 1. Make a connection with the database it assumes that it allready exists. Summary: Getting the next auto increment from the given table ($table) is handy for example giving image names the same name as the auto increment id. WARNING: When multiple connections use the same table at the same time the next auto increment value could be wrong.
<?php
// Author: Ruben Vandenbussche
// Website: http://www.RVandenbussche.nl
// Contact: info (at) RVandenbussche (dot) nl
// Date: 11 Nov 2008
//*******************************************
// Script: Get Auto Increment v1.0
//It does:
// 1. Get the next auto increment from the table.
//*
//It doesn't:
// 1. Make a connection with the database it assumes that it allready exists.
//*******************************************
// Summary:
// Getting the next auto increment from the given table ($table) is handy for example giving
// image names the same name as the auto increment id.
//WARNING:
//When multiple connections use the same table at the same time the next auto increment could
//be wrong.
//Script start here.
function getAI($table){
$query = mysql_query("SHOW TABLE STATUS LIKE '$table' ");
$row = mysql_fetch_array($query);
$auto_increment = $row['Auto_increment'];
mysql_free_result($query);
return ($auto_increment);
}
//get auto increment from database
$id = getAI('article'); //article is the table where we get the auto increment from.
?>
Reacties
0