Re: How to tell if a field type is auto_increment
| From: | John L. Creed | Date: | Tue, 30 Jan 2007 19:30:53 +0000 |
| Subject: | Re: How to tell if a field type is auto_increment | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-43013@lists.php.net to get a copy of this message | ||
Here's what I did wih your help:
function isAutoinc($table,$fieldname){
// returns 0 if false, 1 if true
$breturn = 0;
$sql = "SHOW COLUMNS FROM $table LIKE '$fieldname%' ";
$result = mysql_query($sql) or die("Couldn't open table");
// check column Extra
$row = mysql_fetch_array( $result );
if( $row["Extra"] == "auto_increment" ){
$breturn = 1;
}
mysql_free_result($result);
return $breturn;
}
Thanks again!!!
--
Regards,
John L. Creed
pcExpressWay Consulting
*****************************************
dBASE Gold Charter Member 210
*****************************************
http://www.pcexpressway.com
*****************************************
"Niel Archer" <niel@catweasel.org> wrote in message
news:20070129224943.FD72.NIEL@catweasel.org...
> Hi
>
> Try using:
> SHOW COLUMNS FROM db.table LIKE 'field_name%'
>
> and from the returned row, check the 'Extra' column for 'auto_increment'
>
> Niel